Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this simple code output an error. A fix and explanation would be preferred?

player = script.Parent.Parent
fix = script.Parent:clone()
while true do
wait(40)
script.Parent:remove()
fix.Parent = player
end

3 comments

0

Can you tell us the error?

0

What is the error in your output?

0

Why are you doing this script?

1 answer

From what you've given us and what I've been able to understand,

Considering is one script.

Whats happening:

player = script.Parent.Parent --script.parent.parent is player
fix = script.Parent:clone() --script.Parent was cloned
while true do -- you started a loop
wait(40) --waited 40 seconds
script.Parent:remove() -- removed the scripts parent.
fix.Parent = player -- tried to put the clone into script.parent.parent
end -- ended

When you remove the scripts parent, you remove the script and it is unable to continue after that. So, did this error, or not do what you expected?

This discussion is preserved as it was. New answers, comments, and votes are closed.