Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

2 comments

0

So D oI insert into text button or leave it out in gui?

0

Into the TextButton

This discussion is preserved as it was. New answers, comments, and votes are closed.