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

FireClient: player argument must be a Player object?

Asked by 4 years ago
Edited by Ziffixture 4 years ago

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) 
0
How do you accept the manual chore of deleting indentation that is specifically automated, for the central purpose of making readable code? Ziffixture 6913 — 4y

2 answers

Log in to vote
0
Answered by
iuclds 720 Moderation Voter
4 years ago

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
0
pls upvote i want professor iuclds 720 — 4y
0
Sure no problem ill give you an upvote but it says No Player Object found so the code still doesent work. ezkatka1 50 — 4y
0
Nvm i cant give an upvote apparently i need 25+ reputation ezkatka1 50 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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) 

Answer this question