Prints Player Name not Value REMOTE EVENTS

Hi when i FireServer(player, equip) and then on my server script i print (player, equip),It just says my username twice.

LOCAL SCRIPT

local ItemFrame = script.Parent.Frame.ScrollingFrame

local Trail = game.ReplicatedStorage["RainbowTrail"] -- Don't Put Serverstorage as client can't access serverstorage




wait(player.Character:WaitForChild("HumanoidRootPart"))
local success, hasPass = pcall(function() -- Changing the pcall to the correct format
	return MarketPlaceService:UserOwnsGamePassAsync(player.UserId, RainbowpassID)
end)

if success then -- Checking if successful
	if hasPass then 
		
		local clone = script.Parent.Frame.ScrollingFrame.TrailSample:Clone()

		clone.ImageLabel.Image = "http://www.roblox.com/asset/?id="..10939695942
		clone.Parent = script.Parent.Frame.ScrollingFrame

		clone.Visible = true
		clone.Equipped.Visible = false
		
		
		local equip = clone.Equip
		
		
		
		
		
		equip.MouseButton1Click:Connect(function(equipped)
			equip.Name = "RainbowTrail"
			
			game.ReplicatedStorage.EquipTrail:FireServer(player, equip)
			
		end)
		
		
print("Playerhaspass")
		
	end
end

SERVER SCRIPT

game.ReplicatedStorage.EquipTrail.OnServerEvent:Connect(function(player, equip)
	
print(player, equip)	
	
end)

Does anyone know why this is? Thankyou!

You don’t have to send the player instance when calling FireServer() but if your intention is to pass another player and not the client calling it then just add another value in the OnServerEvent

game.ReplicatedStorage.EquipTrail.OnServerEvent:Connect(function(player, player2, equip)
print(player2, equip)	
end)

Whenever you use FireServer(), you should omit the player parameter. .OnServerEvent() assumes the player as the first parameter already.

Right now, the parameters present on the server are (player, player, equip).

i removed player from OnServerEvent:Connect(Function(equip)

and now when it prints out (player, equip)

it prints Nil, t3h1dy

It shouldnt be printing my username, I need it to print RainbowTrail as thats what Equip is

and it doesnt find the player since it prints nil

You should remove the player parameter for FireServer(), not the .OnServerEvent()

okay and now it prints

t3h1dy, nil

how would i make it print Equip.Name since thats what i am FireServer

these lines

local clone = script.Parent.Frame.ScrollingFrame.TrailSample:Clone()

		clone.ImageLabel.Image = "http://www.roblox.com/asset/?id="..10939695942
		clone.Parent = script.Parent.Frame.ScrollingFrame

		clone.Visible = true
		clone.Equipped.Visible = false
		
		
		local equip = clone.Equip

Suggests that equip is parented to a UI element. If that’s the case, the server can’t see a UI element that is only on the client. The client is sending the server an object that does not exist on the server, hence the nil in the print.

1 Like

When firing to the server, the OnServerEvent always receives the player first.
Meaning you do not have to send the player using FireServer.

So, change

game.ReplicatedStorage.EquipTrail:FireServer(player, equip)

To this

game.ReplicatedStorage.EquipTrail:FireServer(equip)

Don’t mess with the server.

Also, if you want to send the equip.Name you would want to say

equip.MouseButton1Click:Connect(function(equipped)
			equip.Name = "RainbowTrail"
			
			game.ReplicatedStorage.EquipTrail:FireServer(equip.Name)
			
		end)

Why did it reply to you, when I replied to her? Weird.
@t3h1dy

2 Likes