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

Script works in Studio, but not in a server? (Checked the blog post, nothing worked, though.)

Asked by 8 years ago

I'm trying to change the color of a part if a player is within 40 studs. It works on studio, but not in a server.

local plrs={}

game.Players.PlayerAdded:connect(function(player)
    table.insert(plrs,player)
end)

local part=script.Parent.Ball

while wait() do
    for i,v in pairs(plrs) do
        if (v.Character.Torso.Position-part.Position).magnitude>40 then
            script.Parent.Ball.BrickColor=BrickColor.new("Shamrock")
            script.Parent.Eye1.BrickColor=BrickColor.new("Forest green")
            script.Parent.Eye2.BrickColor=BrickColor.new("Forest green")
        elseif (v.Character.Torso.Position-part.Position).magnitude<=40 then
            script.Parent.Ball.BrickColor=BrickColor.new("Really red")
            script.Parent.Eye1.BrickColor=BrickColor.new("Maroon")
            script.Parent.Eye2.BrickColor=BrickColor.new("Maroon")
        end
    end
end
0
"Checked the blog post, nothing worked, though." SimplyRekt 413 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

I fixed when that happened to me by putting a "wait(.1)" at the top of the script. Good luck!

Ad

Answer this question