I'm trying to give players different colored particles when they reach a certain amount of Money. i have the following Script working perfectly with no errors in studio, however it does nothing in server.
The hierarchy is as follows game.StarterPlayer.StarterCharcterScripts.Part.Script, ParticleEmitter
FE is OFF, and No error present themselves.
I am extremely new with no prior knowledge to scripting, learning from vids and editing for days until something works, an explanation of how i've gone wrong or a point to an alternative method would be most appreciated.
thanks in advance.
local player = game.Players.LocalPlayer local money = player.leaderstats.Money while true do wait() if money.Value < 1000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(1,1,1)) elseif money.Value > 999 and money.Value < 2500 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(0,0,1)) elseif money.Value > 2499 and money.Value < 5000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(1,0,1)) elseif money.Value > 4999 and money.Value < 10000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(0,1,0)) elseif money.Value > 9999 and money.Value < 25000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(0,1,1)) elseif money.Value > 24999 and money.Value < 75000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(1,0,0)) elseif money.Value > 74999 and money.Value < 500000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(0,0,0)) elseif money.Value > 499999 and money.Value < 1000000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(1,1,0)) end end end)
Okay sorry about my previous answer I was thinking of C++ lmao. Here's you correct answer:
game.Players.LocalPlayer:WaitForChild("leaderstats") money = game.Players.LocalPlayer.leaderstats.money money.Changed:connect(function() if money.Value < 1000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(1,1,1)) elseif money.Value > 999 and money.Value < 2500 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(0,0,1)) elseif money.Value > 2499 and money.Value < 5000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(1,0,1)) elseif money.Value > 4999 and money.Value < 10000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(0,1,0)) elseif money.Value > 9999 and money.Value < 25000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(0,1,1)) elseif money.Value > 24999 and money.Value < 75000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(1,0,0)) elseif money.Value > 74999 and money.Value < 500000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(0,0,0)) elseif money.Value > 499999 and money.Value < 1000000 then script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame script.Parent.ParticleEmitter.Color = ColorSequence.new(Color3.new(1,1,0)) end end)
Let me know if it works. I'm pretty sure your while true is causing problems. I also added a WaitForChild for precaution.