Okay, so I am making a CTF (Capture the flag) game and I made a touched flag script.
but when I ran it, my computer froze then rebooted! It could very possibly be that it ran for too much time, but how do I fix it?
I have not tried any solutions, because I am afraid it will happen again, can someone please help me fix it? I am afraid that it will do something to my computer…
local clone
local weld
script.Parent.Touched:Connect(function(hit)
if(game.Players:GetPlayerFromCharacter(hit.Parent)) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if(player.Team == game.Teams.Red) then
clone = script.Parent.Parent:Clone()
clone.Parent = hit.Parent
weld = Instance.new("Weld")
weld.Parent = clone
weld.Part0 = clone
weld.Part1 = hit.Parent.UpperTorso
elseif(player.Team == game.Teams.Red) then
if(weld == nil and clone ~= nil) then
clone:Destroy()
end
end
end
end)