My RemoteEvent isn't getting a variable sent

I am trying to send an IntValue in a Gui to the server, But it is being sent as nil no matter the number.

I have tried to set it to a solid number, It still printed “nil”.

script.Parent.MouseButton1Click:Connect(function(plr)
local id = script.Parent.Parent.RoomValue.Value – i have set this to even just “3”, It still returns nil
game.ReplicatedStorage.Books.UnBook:FireServer(plr,id)
end)

This is on server

game.ReplicatedStorage.Books.UnBook.OnServerEvent:Connect(function(plr,id)
print(id)
end)

it prints “nil”, If I print “id” on the client it prints “201”, Which is correct

I really need help, Thank you.

When you fire the server, you don’t need to put the player argument in there. You can just do

game.ReplicatedStorage.Books.UnBook:FireServer(id)

You need to keep the player in the onserverevent though

4 Likes

And also, GuiButton.MouseButton1Click doesn’t has a player argument, ClickDetector.MouseClick does.

3 Likes

Thank you soo much! This has been giving me headaches all day! Never knew such a simple thing could stop it. Thanks.

You could send the player, but it’s not needed as it’s automatically sent to server.
However, in this case, just do: :FireServer(id)

1 Like