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)

6 comments
What line does the error appear on?
on line 4 in the "Script"
That means that the error probably appears in the function. Is that the entire error output?
yes
That error normally appears when you call a function with the wrong type of argument. What type of value is "plr"?
"plr" is a value from a PlayerAdded function andline4 is in that function because of leaderboard