Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

FireClient: player argument must be a Player object ?

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 ?

5 comments

0

First of all, Where is the Server script's parent with?

0

game.workspace.SONIC.ChasingStatus

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

0

like this ? : (in server script a line 46) Remote:FireClient(v, v.Name)

0

Yea

1 answer

✓ Accepted answer
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)

9 comments

0

okay, i will try this

0

nothing is printed , would I have missed something?

0

the error has disappeared, but now the message doesn't appear, and I know if I missed something

0

You're not just randomly firing it as soon as the game starts right? That would cause it not to appear

0
  • ,
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)

0

He mean that the script didnt fires after you pressed play. It fires after some algorithms

0

fixed !

0

You are welcome)

This discussion is preserved as it was. New answers, comments, and votes are closed.