Ad
Log in to vote
0

While True Script Wont Work More Than Once?

Asked by 11 days ago

This script will work only once, then it doesn't work anymore. The "RedBall" string changes correctly every time. It's something to do with the looping, it only does it once.

while true do
    wait()
    if game.ReplicatedStorage.RedBall.Value=="true" 
        then wait()
        local newItem = game.ReplicatedStorage.Football:Clone()
        newItem.Handle.CFrame = CFrame.new(-189.549, 1.8, -37.55)
        newItem.Parent = workspace
        newItem.Football.Name = "Handle"
        wait(4)
        game.ReplicatedStorage.RedBall.Value = "false"
    end
end

1 answer

Log in to vote
0
Answered by 11 days ago

You check if the redball's value is "true", but at the end of the if set it's value to "false", meaning that in the next iteration of the loop, the if statement is now false so it won't execute, so it seems like it's "stopped looping" when it is still looping, it's just the check isn't succeeding.

Until you change the value of RedBall to "true" again the loop will infinitely skip over the if statement.

0
Yeah, but I have an outside script setting the value to true again once I interact with something and it does nothing. NortonHDD 14 — 11d
0
huh, weird. Are you sure you're setting the value correctly? Like setting it to "true" instead of literal true? BrimoireGrimoire 21 — 10d
Ad

Answer this question