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

Remote Events Not Working For Some Reason?

Asked by 7 years ago

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!

1
because there's no 'player' parameter for OnClientEvent, and there's no need for one, since you can just use game.Players.LocalPlayer Perci1 4988 — 7y
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. outlook1234567890 115 — 7y
0
You don't have to worry about that. FireClient only fires for one player. cabbler 1942 — 7y

1 answer

Log in to vote
2
Answered by 7 years ago
Edited 7 years ago

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

Ad

Answer this question