How do I make it so a Remote Event only fires for one player?
My Code:
Local Script:
local Event = game:GetService("ReplicatedStorage").Events.TradeRequest
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local PlayerID = LocalPlayer.UserId
script.Parent.MouseButton1Click:Connect(function()
Event:FireServer(PlayerID)
end)
Server script:
game.ReplicatedStorage.Events.TradeRequest.OnServerEvent:Connect(function(Player,PlayerID)
script.Parent.Visible = true
script.Parent.Desc.Text = Player.Name.." sent you a trade request!"
end)
local Storage = game:GetService("ReplicatedStorage")
local ObjectValue = Storage.ObjectValue
---some other variable stuff
script.Parent.MouseButton1Click:Connect(function()
if LocalPlayer.Name == ObjectValue.Value.Name then
Event:FireServer(PlayerID)
end
end)
yes (u will have to choose a player in the server script then set the player name as the value)
if u are going with player name but not player object then use StringValue