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

What's wrong with this?

Asked by
RoyMer 301 Moderation Voter
9 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

Why is this not working?

local player = game.Players.LocalPlayer 
local name = player.ds:FindFirstChild(script.Parent.Parent.Name) 

while true do
if player.ds:FindFirstChild(name).Value == 1 then
    script.Parent.BackgroundColor3 = Color3.new(16/255,134/255,46/255)
    wait(.1)
    script.Disabled = true
end
end

1 answer

Log in to vote
0
Answered by 9 years ago

The reason it may not be working is because if the value is not 1 the loop would skip over that section that has the wait in it. This would cause an endless loop that does not wait which crashes Roblox. The following code may fix your problem or at least allow the output to show your problem. All I did was change while true do to while wait() do which causes the script to wait a little bit before each time it goes through the loop. This will not make any noticeable change to what the script was intended to do but does allow Roblox to run.

local player = game.Players.LocalPlayer 
local name = player.ds:FindFirstChild(script.Parent.Parent.Name) 

while wait() do
if player.ds:FindFirstChild(name).Value == 1 then
    script.Parent.BackgroundColor3 = Color3.new(16/255,134/255,46/255)
    wait(.1)
    script.Disabled = true
end
end

Ad

Answer this question