Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 comments

0

"Checked the blog post, nothing worked, though."

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.