RemoteEvent messing up my values

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? What I’m trying to achieve is to fire a remote event when I buy a gamepass and sned the player name, gamepass id and gamepass name.

  2. What is the issue? When I’m trying to buy my gamepasses as a test, my prints are printing out my player name twice and id once, this makes it really hard to find the gamepass value in the player in my script.

Screenshot 2023-01-01 045148

Local Script:

selected:FindFirstChild("GP"):FindFirstChild("Purchase").MouseButton1Click:Connect(function()
		local GPNAME = tostring(selected:FindFirstChild("GP"):FindFirstChild("GPName").Text)
		local gpassID = gps.Gamepasses[GPNAME]
		mps:PromptGamePassPurchase(plr, gpassID)
		
		game.ReplicatedStorage.Remotes.BoughtGamepass:FireServer(plr, gpassID, GPNAME)
	end)

Server Script

game.ReplicatedStorage.Remotes.BoughtGamepass.OnServerEvent:Connect(function(plr, gpassID, GPNAME)
	print(plr)
	print(gpassID)
	print(GPNAME)
end)
  1. What solutions have you tried so far? I looked for some answers in the Devforum but didn’t get the answer needed, I tried one thing where I made more variables in the remote function but then I got another Player twice, GamepassId once and Gamepass name once. it worked but I don’t really don’t want extra lines of code just for one value

I cant seem to solve this problem alone so some help would really help🙂

and Happy new years!:tada::partying_face:

When firing a remote event you don’t have to state the player as a variable. It automatically makes it a variable for you. So you’d fire it like this:

game.ReplicatedStorage.Remotes.BoughtGamepass:FireServer(gpassID, GPNAME)
1 Like

You are sending this

game.ReplicatedStorage.Remotes.BoughtGamepass:FireServer(plr, gpassID, GPNAME)

But automatically remote events when firing servers set the first value as the player that fires it so what the server is receiving is, the player that fired the event, the “plr” value, the “gpassID” value, the " GPNAME" value.so if you remove the “plr” value from your fire server it might work.

1 Like

i tried that but then my gpassID value prints as my player

So you took out the plr value in the fireserver in the local script?

yes i have, havetohavemorechar

i will try after i get unbanned lol, got falsely banned

i ddint read it right im truly sorry but since u sent it first u can have the solution (:slight_smile:

thank you so much this helped me alot and ive learned a new thing with remotes(:slight_smile:

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