I get this error FireClient: player argument must be a Player object idk how to fix it i've been trying but i cant seem to fix is i would appreciate if someone helps.
local Humanoid = script.Parent.Humanoid function kill() local Tag = Humanoid:findFirstChild("creator") if Tag ~= nil then if Tag.Value ~= nil then local Leaderstats = Tag.Value:findFirstChild("leaderstats") if Leaderstats ~= nil then Leaderstats.Souls.Value = Leaderstats.Souls.Value + 250 --Change Money to the stat that is increased. local Player = game.Players:GetPlayerFromCharacter(Tag.Parent) game.ReplicatedStorage.SoulsEvent:FireClient(Player) wait(0.1) script:remove() end end end end Humanoid.Died:connect(kill)
Simply, firing clients must have a player instance as the first argument. Tag.Parent is the Humanoid, so you have to either use Tag.Parent.Parent (for any part which is a child of the character) or Tag.Parent.Parent.Parent (if hit is an accessory). However, I'd prefer the code below.
local Player = game.Players:FindFirstChild(Tag.Parent.Parent.Name) if not Player then Player = game.Players:FindFirstChild(Tag.Parent.Parent.Parent.Name) end if Player then game.ReplicatedStorage.SoulsEvent:FireClient(Player) else warn('No player object found') end
If anyone needs the same thing i got it to work now
local Humanoid = script.Parent.Humanoid function kill() local Tag = Humanoid:FindFirstChild("creator") if Tag ~= nil then if Tag.Value ~= nil then local Leaderstats = Tag.Value:findFirstChild("leaderstats") if Leaderstats ~= nil then Leaderstats.Souls.Value = Leaderstats.Souls.Value + 250 --Change Money to the stat that is increased. local Player = Tag.Value game.ReplicatedStorage.SoulsEvent:FireClient(Player) wait(0.1) script:remove() end end end end Humanoid.Died:connect(kill)