Help with script for GUI [solved]

I’m certainly not a scripter like you, but I need your help, the fact is that I create a game in the likeness of a clicker, I tried all the guides myself, I wrote scripts, I used blanks from the toolbox, but works before, the local script saved the changed stats, but now it does it visually, I tried it create a script without local but it just doesn’t respond to any actions i need help if you know how to solve it then write here is the script i use thanks in advance!
–Script
local player = game.Players.LocalPlayer
local coins = player:WaitForChild(“leaderstats”):WaitForChild(“Coins”)

db = false

function clicked1()
if db == false then
local clickx = script.Parent.Parent.Parent.ClickX.Value
db = true
coins.Value = coins.Value + clickx print(“Added Coins!”)
wait(0.1)
db = false
end
end

script.Parent.Parent.Click.MouseButton1Click:Connect(clicked1)
script.Parent.Parent.Click.TouchTap:Connect(clicked1)

1 Like

Does the output give any errors?

1 Like

Hi, Can you tell me what’s the error with the error with the code or the problem?

1 Like

that changing stats but only visual i want real change

So a change on the server not client?

1 Like

no it not send error i idk how to fix i lose 2 days for it :sob:

If so then use a Remote event.

1 Like

As @lilmazen1234 said, you are changing the stats on the client. You need to fire a remote and have the server add it.

2 Likes

Here is the script, Add a remote event in ReplicatedStorage called “Clicked”

local player = game.Players.LocalPlayer
local coins = player:WaitForChild(“leaderstats”):WaitForChild(“Coins”)

db = false

function clicked1()
if db == false then
local clickx = script.Parent.Parent.Parent.ClickX.Value
db = true
game.ReplicatedStorage.Clicked:FireServer(clickx.Value)
wait(0.1)
db = false
end
end

script.Parent.Parent.Click.MouseButton1Click:Connect(clicked1)
script.Parent.Parent.Click.TouchTap:Connect(clicked1)

Add a Server script in ServerScriptService

game.ReplicatedStorage.Clicked.OnServerEvent:Connect(function(Player, ClickxValue)
-- Give the Player Coins/Clicks now example down below.
Player.leaderstats.Coins.Value += ClickxValue
end)
2 Likes

thanks! this text box dont post my reply if it not have some characters

Did it work?
If so please mark it as a solution.

1 Like