✓ Accepted answer
The issue isn't the remote event itself, it's your usage of MouseButton1Up. The player who clicked whatever GuiButton is not the parameter of the event. Instead, the parameters are as follows:
GuiButton.MouseButton1Up:Connect(function(x,y)
end)
In fact, you don't even need to get the player that way. Since you're using a LocalScript, you can simply access the LocalPlayer. The truth is, though, that you don't need the LocalPlayer at all. :FireServer() has no required arguments! You may send variable information through this method if necessary, but the player is not required. This is because the server will recognize automatically what client fired the event. As such, OnServerEvent has a default parameter of player, being the player who fired the event.
local replicate = game:GetService("ReplicatedStorage")
script.Parent.MouseButton1Up:Connect(function()
replicate.speed:FireServer()
end)
game:GetService("ReplicatedStorage").speed.OnServerEvent:Connect(function(player)
print(player.Name .. " has bought the thing")
end)
Again, note the fact that player being a parameter of OnServerEvent has nothing to do with the fact that you were sending it through the remote event previously. It is simply the defaut parameter.
3 comments
i can't tell because of how small the context is, but is the first script which fires the remote event a server script or a localscript?
i should also mention that you don't have to send "player" when firing to the server, it will send it without your consent as a way of security. it would be ridiculous if we could tamper with that.
also if this is server-server communication then use a bindable event or something