I was working on a clicker game, and I was trying to implement a click multiplier function like most clickers have.
game:GetService("ReplicatedStorage").PlsNo.Buy.OnServerEvent:connect(function(player, item) if item == "DPC" then if player.leaderstats.Dogecoin.Value >= player.Assets.DPCPrice.Value then player.leaderstats.Dogecoin.Value = player.leaderstats.Dogecoin.Value - player.Assets.DPCPrice.Value player.Assets.DPC = player.Assets.DPC*2 player.Assets.DPCPrice.Value = player.Assets.DPCPrice.Value*2 end end end)
Whenever I fire this remote with the argument "DPC", it returns "DPC is not a valid member of remote event" any help would be appreciated. Thanks.
PS: It indeed says OnServerEvent:connect(function(player, item) You cannot see the "player" but if you check via source code, you will see that it is actually there. That is not the issue.
Hello! I'm BlackOrange3343 and I'll be helping you today.
I have noticed that the comments technically answer your question but I'll provide a code example just in case.
So, when firing to the server you can pass arguments inside the parameters but the order is a little different. When you do :FireServer()
there is a invisible argument that sends the Player to the server. This tells the server which player has fired the event.
So, when firing arguments you have to be careful about the order.
local RemoteEvent = ... local Button = ... Button.MouseButton1Down:Connect(function() RemoteEvent:FireServer(Arg1) -- Arg1 is whatever you want to send end)
On the server:
local RemoteEvent = ... RemoteEvent.OnServerEvent:Connect(function(Player, Arg1) -- As you can see arg1 comes second. The first argument in the parameter will always be Player end)
I'm not entirely sure where your error is because it seems like the error is not coming from the script you provided. When firing from the client your line should look like RemoteEvent:FireServer('DPC')
. Make sure you are using the correct Remote Event and make sure there is no more then 1 OnServerEvent
event. This might be triggering many code at once.
Next time please provide the line where it states the error and all the scripts that may be related to the issue.
Also make sure to match up the Arg1 and as you can see the order is moved over by 1.
If you do edit your question make sure to notify me, I'll get back to you as soon as possible.
Hopefully this helped!
Best of luck developer!
BlackOrange3343
PS: Use the comments that people have commented. They're useful.