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

Remote Events Not Working For Some Reason?

Well im trying to make this script and I have filtering enabled on and for some reason in the onclientevent part i put in player and in the local script it does not get that but instead thinks its the next variable.

Server Script:

game.ReplicatedStorage.ItemLook:FireClient(player, script.Parent.NameValue.Value, script.Parent.CashValue.Value, script.Parent.Desc.Value)

Local Script

game.ReplicatedStorage.ItemLook.OnClientEvent:connect(function(player, name, cash, desc)

Please help!

3 comments

1

because there's no 'player' parameter for OnClientEvent, and there's no need for one, since you can just use game.Players.LocalPlayer

0

The thing is though im checking in the local script to see if the player's name sent from the remote event is the same as the local players name.

0

You don't have to worry about that. FireClient only fires for one player.

1 answer

✓ Accepted answer

Hey outlook1234567890,

So, as you can probably tell from the comment by Percil, the problem with your script is that the OnClientEvent, does not have the parameter of player. Now, I saw your comment saying you want to check the player's name. Well, you can easily send in the Player's name from firing the :FireClient() function by just making another argument in there. Ok, so I'll provide you with a personal example below of how you can do this.

####Personal Example

---- SERVER SCRIPT ----
game.ReplicatedStorage.ItemLook:FireClient(player, player.Name, script.Parent.NameValue.Value, script.Parent.CashValue.Value, script.Parent.Desc.Value)
---- SERVER SCRIPT ----


---- LOCAL SCRIPT ----
local plr = game.Players.LocalPlayer;

game.ReplicatedStorage.ItemLook.OnClientEvent:connect(function(player_name, name, cash, desc)
	if player_name == plr.Name then
		print("Yes, the player is the correct player.");
	end
end)
---- LOCAL SCRIPT ----

##Well, I hope I helped in one way or another.

~~ KingLoneCat

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