Getting a player's name that triggered a RemoteEvent

Hey! :wave:

As you can see in the scripts below, I’m trying to display the name of a player that says the ‘!pts’ command and triggers the RemoteEvent on the GUI that pops up, but I’m unsure how to transfer it from the server script to the local script and it’s currently showing the localplayers’ name. If I haven’t explained this well enough, let me know below and I’ll provide some further clarity on it. Thanks for everyone who’s trying to help! :heart:

ServerScript:

 game.Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		if Message == "!pts" then
			game.ReplicatedStorage.PTSRequestGrant:FireAllClients(Player.Name)
		end
	end)
end)

LocalScript:

local player = game.Players.LocalPlayer
game.ReplicatedStorage.PTSRequestGrant.OnClientEvent:Connect(function()
local frameclone = player.PlayerGui.PTSDisplayer.HolderFrame.SampleFrame:Clone()
frameclone.Parent = script.Parent.HolderFrame
frameclone.Visible = true
frameclone.Text = player.Name.." has requested PTS!"
end)

We need to grab the player parem, so just do

game.ReplicatedStorage.PTSRequestGrant.OnClientEvent:Connect(function(PTSName)
-- Rest of your code goes here
frameclone.Text = PTSName.." has requested PTS!"

2 Likes

You’re using the local player’s name but I assume the local player isn’t the one who requested for pts?

Thank you! :hearts:

(30 ch@rsssssssss)

1 Like