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

(UNANSWERED) How To Make A Clicker (Like Cookie Clicker Into a Gui?)

Asked by 9 years ago

Well I got The Script but I dont know how to convert it into a gui. How will i be able to do that?

Here is the script

--Basically checks if the toucher of the button is a player, then adds money to that player.

local ting = 0 --debouncer

function onTouched(hit)

    if ting == 0 then --debounce check
    ting = 1 --activate debounce
    check = hit.Parent:FindFirstChild("Humanoid") --Find the human that touched the button

    if check ~= nil then --If a human is found, then

        local user = game.Players:GetPlayerFromCharacter(hit.Parent) --get player from touching human
        local stats = user:findFirstChild("leaderstats") --Find moneyholder

        if stats ~= nil then --If moneyholder exists then
            local cash = stats:findFirstChild("Cookie") --Get Cookie
            cash.Value  = cash.Value +5 --increase amount of money by the number displayed here (500)
            wait(0) --wait-time before button works again
        end

    end

    ting = 0 --remove debounce
    end

end

script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
1
Answered by 9 years ago

Make this a local script, then try this code:

--Basically checks if the toucher of the button is a player, then adds money to that player.

local ting = 0 --debouncer

function onClicked()

    if ting == 0 then --debounce check
    ting = 1 --activate debounce
    player = game.Players.LocalPlayer

    if player ~= nil then --If a human is found, then

        local stats = player:FindFirstChild("leaderstats") --Find moneyholder

        if stats ~= nil then --If moneyholder exists then
            local cash = stats:FindFirstChild("Cookie") --Get Cookie
            cash.Value  = cash.Value +5 --increase amount of money by the number displayed here (500)
            wait(0) --wait-time before button works again
        end

    end

    ting = 0 --remove debounce
    end

end

script.Parent.MouseButton1Clicked(onClicked)


If this worked, please accept this as the answer so that more people don't answer this question.

0
So D oI insert into text button or leave it out in gui? Blitz12234 10 — 9y
0
Into the TextButton SlickPwner 534 — 9y
Ad

Answer this question