Why remote event doesn't pass info? [SOLVED]

After I press the button and print the info on the client, everything seems normal, but when I print the passed info on the server side, it only passes parent.Name without LocalPLayer.Name. I used a remote event

it may be because I used local player name but I don’t know how to pass player’s name a diff way

server side:

game.ReplicatedStorage.PlayerDrop.OnServerEvent:Connect(function(item, player)
	local p = game.Players:FindFirstChild(player)
	local i = p.Inventory:FindFirstChild(item)
	
	local part = game.ReplicatedStorage.Materials:FindFirstChild(item):Clone()
	part.Parent = game.Workspace
	part.Position = p.Character.PrimaryPart.Position + Vector3.new(0,6,0)
	
	i -= 1
end)

client side:

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.PlayerDrop:FireServer(script.Parent.Name, game.Players.LocalPlayer.Name)
end)

explorer:
Zrzut ekranu 2023-08-2 o 22.04.06

1 Like

The first parameter of the function in an OnServerEvent connection is always a player instance.

1 Like

So I have to invert the parameters? If so then It didn’t work

Well, not exactly, you are sending 2 params and if you invert params it would be the same. If you want all 2 params you need to include player before the ones you passed.

Now the player is the first parameter (and it works) but it doesn’t pass the other one

params should look like:

player, item, playername

ideally, you would be getting player’s name from player.Name

works perfectly thank you kind man, you’re saving my code again

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.