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