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 ?

Asked by 5 years ago

hello

I've been struggling since earlier for something that looks easy. I'm not very comfortable with remotes, so I don't really know how it works.

I have a script error: 13:56:37.349 - FireClient: player argument must be a Player object

and I'm not sure how to fix it.

here are the two scripts

server script :

value = script.Parent.Value.Value

torsop = script.Parent.Parent.Parts.Torsoe
head = script.Parent.Parent.Parts.Heade
fly = script.Parent.Parent.Parts.SonicFly
lefta = script.Parent.Parent["Left Arm"]
righta = script.Parent.Parent["Right Arm"]
leftl = script.Parent.Parent["Left Leg"]
rightl = script.Parent.Parent["Right Leg"]
eye1 = script.Parent.Parent.Parts.Eyes1
eye2 = script.Parent.Parent.Parts.Eyes2
-----------------------------------------------------------------------------
local repstorage = game:GetService("ReplicatedStorage")
local Remote = repstorage:WaitForChild("Remote")
-----------------------------------------------------------------------------


----------------------------------- BASIC ATTACK -------------------------------
-------------------------- Sonic kills and chase -------------------------------


    if value == 0 then -- event choice
local active = false -- currently in chase?
local found = false -- anyone within range?
while wait(2) do
    found = false -- reset before checking again
    for i,v in pairs(game.Players:GetChildren()) do
        local range = (v.Character.HumanoidRootPart.Position - Torso.Position).magnitude -- I changed it to HRP instead of Torso, this exists in all humanoids, Torso is R6 only.
        if  range <= 80 then
            found = true
            if not active then
                active = true
                -- start chase
                torsop.Transparency = 1
                head.Transparency = 1 
                righta.Transparency = 1 
                lefta.Transparency = 1 
                leftl.Transparency = 1 
                rightl.Transparency = 1 
                        fly.Transparency = 0
                        eye1.Transparency = 1
                        eye2.Transparency = 0
                -- char change
                    sonic.WalkSpeed = 29

                    Remote:FireClient() --------- The problem is here -----------

                break -- breaks the for loop
            end
        end
    end
    if not found then -- the entire for loop ran without finding anyone
        active = false
        -- stop chase
                torsop.Transparency = 0 
                head.Transparency = 0
                righta.Transparency = 0
                lefta.Transparency = 0
                leftl.Transparency = 0
                rightl.Transparency = 0
                        fly.Transparency = 1
                        eye1.Transparency = 0
                        eye2.Transparency = 1
                -- char change
                    sonic.WalkSpeed = 18

    end
end

    ------------------------------------------------------- 
        end --- end of the script

local script

local repstorage = game:GetService("ReplicatedStorage")
local remote = repstorage:WaitForChild("Remote")

remote.OnClientEvent:connect(function(player)
    print(player.Name.."has fired this event")
end)

any suggestions ?

0
First of all, Where is the Server script's parent with? cherrythetree 130 — 5y
0
game.workspace.SONIC.ChasingStatus sheppard929 9 — 5y
0
On 46 line in FireClient add v, and in localScript you need to remove player in function. So if you want to get player name, you can fire it from server(FireClient(v, v.Name) or game.Players.LocalPlayer.Name HaveASip 494 — 5y
0
like this ? : (in server script a line 46) Remote:FireClient(v, v.Name) sheppard929 9 — 5y
0
Yea HaveASip 494 — 5y

1 answer

Log in to vote
0
Answered by
HaveASip 494 Moderation Voter
5 years ago
Edited 5 years ago
Remote:FireClient(v, v.Name) ---[[ just add here "v" (player object). If you didnt do that, the server didnt know what client to fire, so - error]] ---
---[[v.Name - is firing the player.Name ]]---


--[[ Client Script ]]--
local repstorage = game:GetService("ReplicatedStorage")
local remote = repstorage:WaitForChild("Remote")

 --[[playerName is (v.Name) that you fired from server]]--


remote.OnClientEvent:connect(function(playerName)
    print(playerName.."has fired this event")
end)

0
okay, i will try this sheppard929 9 — 5y
0
nothing is printed , would I have missed something? sheppard929 9 — 5y
0
the error has disappeared, but now the message doesn't appear, and I know if I missed something sheppard929 9 — 5y
0
You're not just randomly firing it as soon as the game starts right? That would cause it not to appear Vulkarin 581 — 5y
View all comments (5 more)
0
+ , HaveASip 494 — 5y
0
I don't know, I'm really a beginner to the script, how do I not fire randomly ? (Sorry if I look stupid ^^ but I've never used the remotes event before) sheppard929 9 — 5y
0
He mean that the script didnt fires after you pressed play. It fires after some algorithms HaveASip 494 — 5y
0
fixed ! sheppard929 9 — 5y
0
You are welcome) HaveASip 494 — 5y
Ad

Answer this question