Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Remote keeps printing my username even though I stated Player and other value?

So I'm making a self check-in, and I'm trying to use a serverside to do all the giving tools and stuff. Here's the code for my economy class

local revent = game.ReplicatedStorage:WaitForChild('class')
local classes = 1
local Player = game.Players.LocalPlayer
local frame = script.Parent.Parent.Parent
local frame2 = script.Parent.Parent.Parent.Parent.endpoint_pass



script.Parent.MouseButton1Click:Connect(function()
frame:TweenPosition(UDim2.new(1, 0,0, 0), 'Out', 'Quint', '1')
frame2:TweenPosition(UDim2.new(0, 0,0, 0), 'Out', 'Quint', '1')
script.Parent.Parent.Parent.Parent.exit.Visible = false
revent:FireServer(Player,classes)--Here's remote
end)

Now the code for the serverside script

local revent = game:GetService('ReplicatedStorage').class
local function test (Player,classes)
print(classes)
end
revent.OnServerEvent:Connect(test)

I've ran into this same error one other time, and that was because my first value wasn't Player, but this time it is, why is this happening?

1 answer

✓ Accepted answer

The reason why it is doing this is because you have Player in your :FireServer(). You do not need "Player" in your :FireServer() because it already passes it automatically. So just remove the "Player " in the parentheses of :FireServer() and it should work.

Basically what is happening is because the :FireServer() passes the player automatically, when you have :FireServer(Player, Classes) and then you have (Player, Classes) in your OnServerEvent, Classes in the :FireServer() is actually being assigned to the Player in the OnServerEvent. That's why it's printing your name.

Hopefully that was a good enough explanation, I tried my best to explain it lol.

2 comments

0

Oh wow, thanks!

0

No problem, happy to help.

This discussion is preserved as it was. New answers, comments, and votes are closed.