Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script does not give cash on click for my leader board?

Asked by 5 years ago

I want my script to give me 1 cash when a press a text button. here is my local script in it

local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:FindFirstChild("ButtonClick")

local button = script.Parent

local debounce = false

button.MouseButton1Click:Connect(function()
    if not debounce then
        debounce = true
        local playerpoint = game.Players.LocalPlayer.leaderstats.Points
        remote:FireServer(playerpoint)
        wait(0.01)
        debounce = false
    end
end)

I have a event thing in replicated storage called button click. This is my script in workspace

local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:FindFirstChild("ButtonClick")

remote.OnServerEvent:Connect(function(plr, x)
    x.Value = x.Value +1
end)

Please help me with this

0
In your server script it looks like your just taking the x parameter and adding 1 to it, you never actually added anything to the players leaderstat ForeverBrown 356 — 5y
0
You don't need a debounce variable for what you are attempting. Just remove it and keep the wait in there. Also, consider making the wait time longer, it seems it would trigger multiple times. TheRighteousBuilder 70 — 5y
0
its a text button, the code will only run once per click. If he is only wanting the user to be able to make 1 cash per second then he would need the debounce, but of course if he does not want to set any limits then he could remove the debounce ForeverBrown 356 — 5y

Answer this question