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

Why Does My Raffle Button Not Work?

Asked by
jacobwow 140
10 years ago

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

Log in to vote
1
Answered by
Nickoakz 231 Moderation Voter
10 years ago
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.

Ad

Answer this question