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

Why Does My Raffle Button Not Work?

When I touch it it does nothing at all. There is no error messages or anything. Here is the script:

local Button = script.Parent
local debounce = false

	function onTouch(Brick)
		if debounce == false then
		debounce = true
		local Player = Brick.Parent:findFirstChild("Humanoid")
		if Player ~= nil then
			local Location = game:GetService('Players')GetPlayerFromCharacter(Player.Parent)
			local Nodlas = Location.leaderstats.Gold
			if Nodlas.Value >= 0 then
				Nodlas.Value = Nodlas.Value -1
				local LottoNum = math.random(1,50)
				script.Parent.Parent.Name = "Your Lotto Number Is" .. LottoNum
				wait(3.2)
				if LottoNum == 27 then
					Script.Parent.Parent.Name = "You Won!"
					Player.Parent.Head.face.Texture = "http://www.roblox.com/asset/?id=42110197"
					Location.leaderstats.Gold.Value = Location.leaderstats.Gold.Value + 10000
					wait(4)
					script.Parent.Parent.Name = "Lottery: Jackpot 10,000 Gold"
				else Script.Parent.Parent.Name = "Sorry, Try Again."
					wait(4)
					script.Parent.Parent.Name = "Lottery: Jackpot 10,000 Gold"
				end
				wait(1)
				local debounce = false
			end
		end
	end
end

Button.Touched:connect(onTouch)

1 answer

local Button = script.Parent
local debounce = false

    function onTouch(Brick)
        if debounce == false then
        debounce = true
        local Player = Brick.Parent:findFirstChild("Humanoid")
        if Player ~= nil then
            local Location = game:GetService('Players')GetPlayerFromCharacter(Player.Parent)
            local Nodlas = Location.leaderstats.Gold
            if Nodlas.Value >= 0 then
                Nodlas.Value = Nodlas.Value -1
                local LottoNum = math.random(1,50)
                script.Parent.Parent.Name = "Your Lotto Number Is" .. LottoNum
                wait(3.2)
                if LottoNum == 27 then
                    Script.Parent.Parent.Name = "You Won!"
                    Player.Parent.Head.face.Texture = "http://www.roblox.com/asset/?id=42110197"
                    Location.leaderstats.Gold.Value = Location.leaderstats.Gold.Value + 10000
                    wait(4)
                    script.Parent.Parent.Name = "Lottery: Jackpot 10,000 Gold"
                else Script.Parent.Parent.Name = "Sorry, Try Again."
                    wait(4)
                    script.Parent.Parent.Name = "Lottery: Jackpot 10,000 Gold"
                end
                wait(1)
                debounce = false
            end
        end
    end
end

Button.Touched:connect(onTouch)

Never local debounce or the script will halt on first run.

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