Localscript doesn't recive remote function

I’m making a script when a player is hit, if that player is under lvl 30, the player who attacked, will get a billboardgui with text appearing on the player who he hit, but only visible to the player who attacked. So I made a fireclient with the playerobject from the player who got hit, but then it doesn’t seem like the localscript receives it for some reason. It doesn’t even print out the first line of text.

if game.Players[person].LevelsInfo.Level.Value < 30 then
				print (target.Parent)
				local newplr = game.Players:GetPlayerFromCharacter(target.Parent)
                print (newplr) -- the player who got hit
				game.ReplicatedStorage.Remotes.extras.toolowlvl:FireClient(newplr)
				print ("tolowlvl sent")
				return end -- only a tiny bit of the script 

–// Localscript
game.ReplicatedStorage.Remotes.extras.toolowlvl.OnClientEvent:Connect(function(player)
print (“tolowlvl recived”)
local clone = game.ReplicatedStorage.toolowlvl:Clone()
clone.Parent = game.Workspace[player.Name].UpperTorso
wait (2.5)
clone:Destroy()
print (“tolowlvl finished”)
end)

If I recall correctly, the first value in FireClient(player) needs to be the player object from PlayerService. You cant send the player’s character

That’s why I used “local newplr = game.Players:GetPlayerFromCharacter(target.Parent)”, and then sent newplr. Shouldn’t that work? I don’t get any error from it.

Don’t remote functions use InvokeClient instead of FireClient? That’s for remote events.

1 Like

Oh yea that’s true, I misspelled it in the title, I am actually using a remote event.

i think at this part is that OnClientEvent dont return the player so that may error your code for some reason as you can basicaly get the player by doing game.Players.LocalPlayer

But I am trying to clone the billboardgui to the player who got hit, but only visible to the player who hit. So that “player” contains the player who got hit, not the localplayer.

Where is the LocalScript located? Also does this print(target.Parent) get printed?

image
Also, your firing it to the player who got hit. I’m not sure if this was intentional

The localscript is in starterplayerscripts, and yes the print target.Parent gets printed. But it only cointains the player’s character, so I used " game.Players:GetPlayerFromCharacter(target.Parent) ", which instead get’s the playersobject, and that also prints the same. But I was supposed to sent this to the player who hit, does that mean is should be FireClient(player.newplr)?

Based on your code it looks like you should be using FireClient(person, newplr)

the person is actually the target.Parent.Name, so basiclly the same as newplr, but not the playerobject. But the player is the player who punched, but it didn’t show in the code I sent. But otherwise, is the first one typed the location it goes too?

FireClient requires the player you want to receive the event to be the first argument
Example: FireClient(playerToRecieve, …)

I think that’s what you’re asking?

1 Like

Does the OnClientEvent function in the localscript also need the “player” as the first argument, or is it automaticly (newplr) the first argument there?

On the client, the arguments are whatever came after the playerToRecieve

FireClient(playerToRecieve, 10, "hello")

Somewhere in a LocalScript

OnClientEvent:Connect(function(theNumber10, greeting)
    
end)
2 Likes

I replied to the wrong person sorry about that