The script below should clone a model from serverstorage into workspace, this way I could reduce lag because unnecessary parts will be in serverstorage. It should clone it when I touch a certain part that is in workspace. (CanCollide = false) This works in Studio but when I try it in game nothing happens when I walk through the part.
Script:
x = 0
game.Workspace.TerrainButton1.Touched:connect(function(part) -- This clones the Terrain
local parent = part.Parent
if game.Players:GetPlayerFromCharacter(parent) then
if x ~= 1 then
local terrain1 = game.ServerStorage.Terrain1
terrain1:clone().Parent = game.Workspace
x = 1
end
end
end)
game.Workspace.HordeButton1.Touched:connect(function(part) -- This clones the Zombies
local parent = part.Parent
if game.Players:GetPlayerFromCharacter(parent) then
if x ~= 2 then
local horde1 = game.ServerStorage.Horde1
horde1:clone().Parent = game.Workspace
x = 2
end
end
end)
game.Workspace.RemoveButton1.Touched:connect(function(part) -- This deletes both the terrain and the zombies
local parent = part.Parent
if game.Players:GetPlayerFromCharacter(parent) then
x = 2
local horde1 = game.Workspace.Horde1
local terrain1 = game.Workspace.Terrain1
if horde1 ~=nil then
horde1:destroy()
end
if terrain1 ~= nil then
terrain1:destroy()
end
end
end)

4 comments
Ok thx! Do I have to do this for the second line too? Or just for variables?
You can try with only variables if it still doesn't work then do it for the second line too, accept the answer if it works ;D
Finally had the time to test it and it works, so thanks a lot again! :D
No Problem! Thanks for accepting my answer :D