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

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

Asked by 7 years ago
player = script.Parent.Parent
fix = script.Parent:clone()
while true do
wait(40)
script.Parent:remove()
fix.Parent = player
end
0
Can you tell us the error? User#15461 0 — 7y
0
What is the error in your output? addictedroblox1414 166 — 7y
0
Why are you doing this script? JasonTheOwner 391 — 7y

1 answer

Log in to vote
2
Answered by 7 years ago

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?

Ad

Answer this question