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

how to get particles on cash level ?

Asked by 6 years ago
Edited 6 years ago

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)
0
Why are u using a while trough loop inside a while trough loop, if you use changed every time it changes a bit it runs that script.. DanielDeJong3 158 — 6y
0
trough = true* DanielDeJong3 158 — 6y
0
like i said i have no knowledge haha, i went ahead and removed the .Changed event though and it is still functioning the same. Works in Studio, Not in Server. Yishles 4 — 6y

1 answer

Log in to vote
0
Answered by
oftenz 367 Moderation Voter
6 years ago

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.

0
thanks for the tweaks, i'll definately use them so it runs on change rather than constantly... i actually just found the problem though and got it working.. turns out i just had to switch to a LocalScript as i was calling LocalPlayer. thanks for the adjustment though :) Yishles 4 — 6y
Ad

Answer this question