Roblox RemoteEvent Wrong Arguments (Player Passed Twice) – Fix
The error
Values arrive wrong in OnServerEvent / 'attempt to index nil' / argument is a Player instead of my data
What it means
RemoteEvent:FireServer(...) automatically sends the calling player as the first argument of OnServerEvent. If you also pass the player yourself, or forget the player parameter on the server, every argument shifts by one.
The fix
-- LocalScript
remote:FireServer("Sword") -- do NOT pass LocalPlayer
-- Script (server)
remote.OnServerEvent:Connect(function(player, itemName)
if typeof(itemName) ~= "string" then return end -- validate client input
print(player.Name, "requested", itemName)
end)Always validate data from clients on the server; exploiters can fire remotes with anything.
Related tools: Roblox script generator · Roblox Lua error fixer · all script generators