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

Data being printed as username?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by
JakyeRU 637 Moderation Voter
4 years ago

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)
Ad

Answer this question