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

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

Asked by 10 years ago

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

Log in to vote
1
Answered by
hiccup111 231 Moderation Voter
10 years ago

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

0
Okay. So Ancestrychange caused the freeze I guess. But ChildRemoved doesn't work. Orlando777 315 — 10y
0
By not work I mean it wont execute line 24 then. Orlando777 315 — 10y
0
Put a couple prints in, before line 24, within the ChildRemove and after it's passed hiccup111 231 — 10y
0
That wasnt it. I just realized what it was. Thanks for helping though. Here's a +1 Orlando777 315 — 10y
0
Glad you found it, and cheers. hiccup111 231 — 10y
Ad

Answer this question