LOCAL SCRIPT
function onTouch() local player = game.Players.LocalPlayer local cashMultiplyer = script.CashMultiplyer.Value game.ReplicatedStorage.Delivered:FireServer(player, cashMultiplyer) end game.Workspace.Brick.Touched:connect(onTouch)
SERVER SCRIPT
game.Players.PlayerAdded:Connect(function(player) game.ReplicatedStorage.Delivered.OnServerEvent:Connect(function(player, cashMultiplyer) print(cashMultiplyer.Name) print(cashMultiplyer) end) end)
The server script prints my username instead of script.CashMultiplyer.Name
LocalScripts will pass LocalPlayer to whatever function is on the receiving end when calling the :FireServer() function. Which means you do not need to create a variable and add it as an argument as it's basically done for you. Fixed scripts:
LocalScript
function onTouch() local cashMultiplyer = script.CashMultiplyer.Value game.ReplicatedStorage.Delivered:FireServer(cashMultiplyer) end game.Workspace.Brick.Touched:connect(onTouch)
ServerScript
game.ReplicatedStorage.Delivered.OnServerEvent:Connect(function(player, cashMultiplyer) print(cashMultiplyer.Name) print(cashMultiplyer) end)