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

Data being printed as username?

So for my game, I'm trying to make a GUI which allows users to enter the ID of a sound and fire it to the server

game:GetService("Players")

script.Parent.MouseButton1Click:Connect(function()
	local player = game.Players.LocalPlayer
	local id = script.Parent.Parent.ThemeId.Text
	game.ReplicatedStorage.DataSaveEvent:FireServer(id)
end)

This is the Localscript that acts as a Save button, ThemeId is a TextBox which allows the user to enter the Id

game.ReplicatedStorage.DataSaveEvent.OnServerEvent:Connect(function(id)
	print(id)
end)

This is the server event, it gets picked up correctly, but when I check the output, it prints my Username instead of the text in the TextBox. Anyone see the issue?

1 answer

✓ Accepted answer

The first parameter of a RemoteEvent/RemoteFunction is always the player who fired it.

This should fix your code:

game.ReplicatedStorage.DataSaveEvent.OnServerEvent:Connect(function(player, id)
     print(id)
end)

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