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

Why is this marble script a glitchy/buggy mess?

Asked by 8 years ago

So im trying to put the players character in a ball so the character and ball roll around. But for some reason 2 balls get cloned and the actual ball doesnt want to roll

local go = false

script.Parent.Touched:connect(function(hit)
    if go == false then
        go = true
        if hit.Parent:FindFirstChild("Humanoid") then
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
            player.PlayerScripts.ControlScript.Disabled = true 
            local clone = workspace.Marble:Clone()
            clone.Parent = hit.Parent.Torso
            clone.CFrame = workspace.MarbleSpawn.CFrame
            clone.Anchored = false
            local weld = Instance.new("Weld")
            weld.Parent = clone
            weld.Part0 = clone
            weld.Part1 = hit.Parent.Torso
            hit.Parent.Torso.CFrame = clone.CFrame
            game.Lighting.Marble:FireClient(player)
            go = false
        end
    end
end)

game.Lighting.Marble.OnClientEvent:connect(function()
    game.Players.LocalPlayer.Character.Humanoid:SetStateEnabled("GettingUp",false)
    game.Players.LocalPlayer.Character.Humanoid:SetStateEnabled("PlatformStanding",true)
    game.Players.LocalPlayer.Character.Torso:WaitForChild("Marble").Rotation = Vector3.new(0,160,0)
    wait(1)
    game.Players.LocalPlayer.Character.Torso:WaitForChild("Marble").Rotation = Vector3.new(0,200,0)
end)

1 answer

Log in to vote
0
Answered by
Scerzy 85
8 years ago

I'm sorry if this isn't correct because I'm not that great of a scripter but I think the script keeps repeating itself because it keeps detecting that "go" is false. When you set it to false at the end the script checks to see if it's false, and since it is it runs through itself again. Then go is set to false again and it continues.

Ad

Answer this question