Hi i had a question because this is the first time i'm using FireClient/FireServer and RemoteEvents.
From what i know FireServer can only be used with a localscript and FireClient can be used on a script (Correct me if i'm wrong).
So i wanted to make a RemoteEvent when i rank up(when the rank value changes) that there will be some Fireworks! But it won't work on the line with:
rank.Changed:connect(function() onRankChanged(plr) end)
everytime it says "unable to cast value to object" and i can't fix it so if you can please say what i need to do :) and what i did wrong!
Thanks! (P.S. I won't give that much of the code because it's something i don't realy want to sare if you know what i mean :P)
--Script rank.Changed:connect(function() onRankChanged(plr) end) function onRankChanged(plr) local leaderstats = game.Players:FindFirstChild(plr.Name):findFirstChild("leaderstats") if (leaderstats ~= nil) then local rank = leaderstats:FindFirstChild("Rank") if plr ~= nil then if game.Players:FindFirstChild(plr.Name) ~= nil then if (rank ~= nil) and (leaderstats ~= nil) then rEvents:FindFirstChild("FireworkEvent"):FireClient(game.Players:FindFirstChild(plr.Name),"Rank Up!") end end end end end
--LocalScript local FWEvent = game.ReplicatedStorage.Events.FireworkEvent FWEvent.OnClientEvent:connect(function() Fireworks(12) end)
rank.Changed:connect(function(plr) -- You need to set player as a received argument. onRankChanged(plr) end)