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

why my script is alaway using the old value?

Asked by 5 years ago

hi, my script is alaway using old value but idk why it's alaway print "" even when i change the value of the string value

while true do
    game:GetService("RunService").Stepped:wait()
    plr = game.Players:FindFirstChild(script.Parent.plr.Value)
    print(script.Parent.plr.Value)
    if game.Players:FindFirstChild(script.Parent.plr.Value) then
        if plr.Character ~= null then
            script.Parent:Sit(plr.Character.Humanoid)
        end
    end
end

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

This might be a solution.

while true do
    wait(1)
    game:GetService("RunService").Stepped:wait()
    plr = game.Players:FindFirstChild(script.Parent.plr.Value)
    print(script.Parent.plr.Value)
    if game.Players:FindFirstChild(script.Parent.plr.Value) then
        if plr.Character ~= nil then
            script.Parent:Sit(plr.Character.Humanoid)
        end
    end
end

You wrote null instead of nil. You also need a wait otherwise it can crash the whole server. This should work now but comment if it does not. This is all i can think of. Hope this helps!

Ad

Answer this question