0% found this document useful (0 votes)
585 views3 pages

Tank Simulator

The document contains Lua code that defines variables for a tank, map, and player objects. It includes functions to search a map for the player's tank, set the tank and map variables, and connect to events when new objects are added to respond and reset the variables. When the player's ammo changes, it will trigger reloading sequences on the tank.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
585 views3 pages

Tank Simulator

The document contains Lua code that defines variables for a tank, map, and player objects. It includes functions to search a map for the player's tank, set the tank and map variables, and connect to events when new objects are added to respond and reset the variables. When the player's ammo changes, it will trigger reloading sequences on the tank.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

local Tank

local Map
local OMap
local Players = game.Players
local LocalPlayer = Players.LocalPlayer

local function search(map)


for i,v in pairs(map:GetChildren()) do
if v.ClassName == 'Model' and v:FindFirstChild('Seat') and 2 >
(game.Workspace[LocalPlayer.Name].HumanoidRootPart.Position -
v.Seat.Position).Magnitude then -- LocalPlayer.Character is nil
Tank = v
Map = map
if OMap == nil then
OMap = map.Name
end
end
end
end

for i,v in pairs(game:GetService("ReplicatedStorage")["RemoteEvents


Folder"]:GetChildren()) do
v.Name = i
end

for i,v in pairs(game:GetService("ReplicatedStorage")["RemoteFunctions


Folder"]:GetChildren()) do
v.Name = i
end

local function set()


for i,v in pairs(game.Workspace:GetChildren()) do
if v.ClassName == 'Folder' and v.Name ~= '[DeathEffects]' then
search(v)
return
end
end
end
set()

game.Workspace.ChildAdded:Connect(
function(c)
if c.Name == LocalPlayer.Name then
wait()
Char = c
set()
end
end
)

local function destroyAll()


for i,model in pairs(Map:GetChildren()) do
if model.ClassName == 'Model' and not model:FindFirstChild('Hull') then
for i,v in pairs(model:GetDescendants()) do
if v.ClassName == 'TouchTransmitter' then
spawn(function()
while v.Parent do
firetouchinterest(Tank.BUMPER, v.Parent, 0)
wait()
if v.Parent then
firetouchinterest(Tank.BUMPER, v.Parent, 1)
end
end
end)
end
end
end
end
end

if Map.Name ~= 'MapOne' then


while true do
wait(3)
destroyAll()
wait(5)
game:GetService("ReplicatedStorage")["RemoteFunctions Folder"]
['8']:InvokeServer('MapOne')
wait()
game:GetService("ReplicatedStorage")["RemoteFunctions Folder"]
['8']:InvokeServer(OMap)
end
end

while wait(5) do
destroyAll()
end

local Tank
local Map
local LocalPlayer = game.Players.LocalPlayer

local function search(map)


for i,v in pairs(map:GetChildren()) do
if v.ClassName == 'Model' and v:FindFirstChild('Seat') and 2 >
(game.Workspace[LocalPlayer.Name].HumanoidRootPart.Position -
v.Seat.Position).Magnitude then
Tank = v
Map = map
return
end
end
end

local function set()


for i,v in pairs(game.Workspace:GetChildren()) do
if v.ClassName == 'Folder' and v.Name ~= '[DeathEffects]' then
search(v)
end
end
end
set()

game.Workspace.ChildAdded:Connect(
function(c)
if c.Name == LocalPlayer.Name then
wait(1)
set()
end
end
)

LocalPlayer.PlayerGui.Ammo.Frame.Value:GetPropertyChangedSignal("Text"):Connect(
function()
if Tank then
wait()
firetouchinterest(Tank['CollisionBox char'], Map.Reload, 0)
wait()
firetouchinterest(Tank['CollisionBox char'], Map.Reload, 1)
end
end
)

You might also like