Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

this short script doesnt work ?

Asked by 9 years ago

can you tell me why this doesnt work? my username is in second.Value but it still doesnt work

while true do
local play2 = game.Workspace:FindFirstChild(second.Value)
play2.Head:Destroy()
wait(1)
end

1 answer

Log in to vote
0
Answered by 9 years ago

Well, there is only one issue I see with this script. When you destroy play2.Head, you are not checking to make sure it is present in the game first. The best method is to use the WaitForChild() function on lines 2 and 3:

while true do
    local play2=game.Workspace:WaitForChild(second.Value)
    play2:WaitForChild("Head"):Destroy()
    wait(1)
end

You can read up more on WaitForChild here. I hope this helped!

Ad

Answer this question