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

"FireClient: player argument must be a Player object?" Even though it is??

Asked by 4 years ago

It basically says that the first argument has to be the player, which it is? Unless I'm wrong but I don't see how I could fix this?

Error: "FireClient: player argument must be a Player object?"

Serverscript In Tool

local Projectile = script.Parent
local Heartbeat = game:GetService("RunService").Heartbeat

while Heartbeat:wait() do
    Projectile.CFrame = CFrame.new(Projectile.Position, Projectile.Position + Projectile.Velocity)
    Projectile.Touched:connect(function(hit)

        local Player = game.Players:GetPlayerFromCharacter(hit.Parent)

        local Model = game.ReplicatedStorage.Morphs.SweetCheeks

        local Event = game.ReplicatedStorage.Events.Morph

        Event:FireClient(Player, Model)

    end)
end

0
You need to filter for the Character Object before using it to uplink a player. This can be done by searching hit.Parent for a Humanoid Object, occasionally provided a secondary Parent climb for potential accessory overlap. Ziffixture 6913 — 4y

3 answers

Log in to vote
3
Answered by
Mayk728 855 Moderation Voter
4 years ago

you shouldn't have a function inside a loop, since it will continuously create a new function when it really isn't necessary. you also need to have the Touched event check if the part touching is an actual player so that it can fire.

fix:

local Projectile = script.Parent
local Heartbeat = game:GetService("RunService").Heartbeat

while Heartbeat:wait() do
    Projectile.CFrame = CFrame.new(Projectile.Position, Projectile.Position + Projectile.Velocity)
end

Projectile.Touched:Connect(function(hit)
    if hit and hit.Parent and hit.Parent:IsA('Model') and hit.Parent:FindFirstChild('Humanoid') then
        local Player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
        local Model = game:GetService('ReplicatedStorage').Morphs.SweetCheeks
        local Event = game:GetService('ReplicatedStorage').Events.Morph
        Event:FireClient(Player, Model)
    end
end)
0
Still shows "FireClient: player argument must be a Player object" Jomeliter 55 — 4y
0
I printed the Player, it outputs as a Nil value Jomeliter 55 — 4y
0
It does sorta work, but the morph doesn't work still so I gotta work on that Jomeliter 55 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Morph Script

local event = game.ReplicatedStorage.Events.Morph

event.OnServerEvent:Connect(function(player, model)
    print("--------")
    print("Player: "..player)
    print("--------")
    print("Morph: "..model)
    print("--------")
    local Char = model:Clone()
    local Pos = player.Character:GetPrimaryPartCFrame()
    local Schar = game.StarterPlayer:FindFirstChild("StarterCharacter")
    game:GetService("StarterPlayer")
    player.Character:Destroy()
    player.Character = Char
    Char.Parent = workspace
    local p = Char:Clone()
    p.Parent = game.StarterPlayer
    Char:SetPrimaryPartCFrame(Pos)
    Schar:Destroy()
    wait(30)

end)
0
what lol 123nabilben123 499 — 4y
Log in to vote
-1
Answered by 4 years ago

If your projectile system is working then you first need to check if it is a player or not.

local Projectile = script.Parent
local Heartbeat = game:GetService("RunService").Heartbeat

while Heartbeat:wait() do
    Projectile.CFrame = CFrame.new(Projectile.Position, Projectile.Position + Projectile.Velocity)
    Projectile.Touched:connect(function(hit)

        local Player = game.Players:GetPlayerFromCharacter(hit.Parent)

    if not Player then return nil end

        local Model = game.ReplicatedStorage.Morphs.SweetCheeks

        local Event = game.ReplicatedStorage.Events.Morph

        Event:FireClient(Player, Model)

    end)
end

If the player variable wasn't an actual player, then the script will still run until there is an function, or property you want to change about the player. Or in all together anything that needs the player for some reason.

Sometimes functions return nil for a reason. They want to indicate that the following value isn't not found or returned.

If I didn't provide a right answer or it still does not work you can ask me

0
It doesn't seem to be firing the event? I added a print to check and nothing appears in the output, no error either? Jomeliter 55 — 4y
0
Also I checked what the player was, it comes out as a nil? Jomeliter 55 — 4y

Answer this question