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

See the player who fiered RemoteEvent? ( Easy )

ServerScript

script.Parent.MouseButton1Click:Connect(function()
		game.ReplicatedStorage.Race:FireAllClients()
end)

LocalScript

game.ReplicatedStorage.Race.OnClientEvent:Connect(function(player)
	print(player) -- Obviously this didn't work, but how can I make it work?
end)

If you need more context - the Player will click a SurfaceGui Button that is in the workspace, It will announce that the race has started. Everyone in the server will get a TextLabel popup saying that the Race has been started by Player.

2 answers

You have it backwards.

The LocalScript should look like:

script.Parent.MouseButton1Click:Connect(function()
        game.ReplicatedStorage.Race:FireServer()
end)

The ServerScript should look like:

game.ReplicatedStorage.Race.OnServerEvent:Connect(function(player)
    print(player.Name) -- Obviously this didn't work, but how can I make it work?
end)

2 comments

0

No, it isn't backwards. I used SurfaceGui on a part! MouseButton1Click is for the TextButton that is inside the SurfaceGui! its the same thing as ClickDetector in this perspective

0

If you want it to print the player's name, you need to use the name property of player.

print(player.Name)

Hope this helped you!

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