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

Can someone explain or point out why this script crashes Roblox? [Sorry, it was just a silly error]

This script was literally working yesterday. Now every time the Player jumps off the seat it freezes and crashes Roblox. I get no errors, parenting is correct. There's no reason it should be acting like this.

seat = script.Parent
function onSitUp(child, Drift, EMP, GUI)
	if child.Parent == nil then
		Drift.Disabled = true
		EMP.Disabled = true
		Drift.Parent = script
		EMP.Parent = script
		GUI.Parent = script
	end
end

function onChildAdded(part)
			local char = script.Parent.Parent.Parent.Parent
			if char then
				local Drift = script["Drift"]
				local EMP = script["EMPscript"]
				Drift.Parent = char
				Drift.Disabled = false
				EMP.Parent = char
				EMP.Disabled = false
				local GUI = script["Controls"]
				local player = game.Players:GetPlayerFromCharacter(char)
				GUI.Parent = player.PlayerGui
				part.AncestryChanged:connect(function(child) onSitUp(child, EMP, GUI, Drift, script.Parent) end) 
			end
end

seat.ChildAdded:connect(onChildAdded)

1 answer

✓ Accepted answer

On Line 24

part.AncestryChanged:connect(function(child) onSitUp(child, EMP, GUI, Drift, script.Parent) end) 

you give 5 variables to the SitUp function, yet the SitUp function only retains three?

Also, why do you need a wait(.1) within an if-statement?

On line 24, try swapping AncestryChange for ChildRemoved

5 comments

0

Okay. So Ancestrychange caused the freeze I guess. But ChildRemoved doesn't work.

0

By not work I mean it wont execute line 24 then.

0

Put a couple prints in, before line 24, within the ChildRemove and after it's passed

0

That wasnt it. I just realized what it was. Thanks for helping though. Here's a +1

0

Glad you found it, and cheers.

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