(RemoteEvent) Issue adding leaderstats

Code

function Buy()
	script.Parent.Parent.Visible = false
	script.Parent.Parent.Parent.Amount.Visible = true
	wait(3)
	script.Parent.Parent.Parent.Amount.Visible = false
	script.Parent.Parent.Parent.Eftpos.Visible = true
	wait(3)
	script.Parent.Parent.Parent.Eftpos.Visible = false
	script.Parent.Parent.Parent.Complete.Visible = true
	wait(3)
	script.Parent.Parent.Parent.Complete.Visible = false
	Buy.leaderstats.Credit.Value = Buy.leaderstats.Credit.Value + 50
end

script.Parent.MouseButton1Click:Connect(Buy)

Problem
After all the GUIs are displayed, the player does not get more Credit.

UPDATE: I have coded a remote event to fire instead of giving the credit. How can I find which player fired the event in my script in serverscriptservice? The GUI is in the players player GUI.

Explorer
image

You’re trying to add the value on a local script it needs to be added on a server side script.

There is 2 point on you can improve, first initialize your variables and second what is that can you explain or show us the entire script :

And I’ve a tips for you, you can do that :

value += 50
--OR--
value -= 50

Have a nice day !

Look at this video maybe right and go 3:01

1 Like

I have made this change and @FireStrykerAzul’s change. The player still doesn’t get any credit.

I didn’t understand what you said, but I do now. I have another question now. I have coded a remote event to fire instead of giving the credit. How can I find which player fired the event in my script in serverscriptservice? The GUI is in the players player GUI.

I think it does that automatically, not sure tho

What do you mean my this? What code would I need?

I don’t know if I understood your question but maybe you are trying to do this:

-- client:
game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireServer()
-- server:
game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent").OnServerEvent:Connect(function(Player)
   -- code here, the first parameter of the event handler is always the Player object of the client that calls it
end)