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

(Solved) Sounds and text not functioning correctly?

Asked by 1 year ago
Edited 1 year ago

I am creating a WOF (Wheel of Fortune) script where admins can say a command to roll a bunch of random words, and during the script it shows in a message the rolling and in a hint the result. Once the rolling stops it will say in the hint text what fortune has been chosen. It is also supposed to play a sound that depends on what fortune was selected, (The fortunes are translated out for the script in a number value.)

I Will post the full code and then post the code where there is a problem.

Full Code:

permission = {"AllenBatman666","bigboy_elias","ninjaspy2319" }
Start = "/rollwof"
End = "/stopwof"
Rolling = false



local function checkClearance(name) 
    for i = 1,#permission do 
        if (string.upper(name) == string.upper(permission[i])) then return true end 
    end 
    return false 
end 



local function onMessaged(msg, recipient, speaker)
    local source = string.lower(speaker.Name)

    if msg == Start or msg == End then

        if (checkClearance(source)) then 

            if msg == Start and Rolling == false and workspace.RollCommandBeingUsed.Value == false then
                workspace.RollCommandBeingUsed.Value = true
                Rolling = true
                script.RisingAction:Play()
                game.Lighting.Blur.Enabled = true
                h = Instance.new("Hint")
                h.Text = "Rolling the Wheel of Fortune!"
                h.Parent = workspace
                m = Instance.new("Message")
                m.Text = "0"
                m.Parent = workspace
                ms = script.Script:Clone()
                ms.Parent = m
                ms.Enabled = true
            end

            if msg == End and Rolling == true then
                script.RisingAction:Stop()
                h.Text = "The fortune chosen is ".. script.GamemodeName.Value.. "!"
                ms.Enabled = false
                if script.ResultNumber.Value == 1 then
                    script.PrettyGood:Play()
                elseif script.ResultNumber.Value == 2 then
                    randomfailuresound = math.random(1,3)
                    if randomfailuresound == 1 then
                        script.Bruh:Play()
                    elseif randomfailuresound == 2 then
                        script.Laugh:Play()
                    elseif randomfailuresound == 3 then
                        script.Fart:Play()
                    end
                elseif script.ResultNumber.Value == 3 then
                    script.SwordSlash:Play()
                    script.DAH:Play()
                elseif script.ResultNumber.Value == 4 then
                    script.Cash:Play()
                elseif script.ResultNumber.Value == 5 then
                    script.WAH:Play()
                elseif script.ResultNumber.Value == 6 then
                    script.Medium:Play()
                elseif script.ResultNumber.Value == 7 then
                    script["Yay!"]:Play()
                elseif script.ResultNumber.Value == 8 then
                    script["Yay!"]:Play()
                elseif script.ResultNumber.Value == 9 then
                    randomfailuresound = math.random(1,3)
                    if randomfailuresound == 1 then
                        script.Bruh:Play()
                    elseif randomfailuresound == 2 then
                        script.Laugh:Play()
                    elseif randomfailuresound == 3 then
                        script.Fart:Play()
                    end
                elseif script.ResultNumber.Value == 10 then
                    script.Highest:Play()
                end
                wait(4)
                h:Destroy()
                m:Destroy()
                game.Lighting.Blur.Enabled = false
                Rolling = false
                workspace.RollCommandBeingUsed.Value = false
            end
        end

    end
end



function onPlayerJoin(newPlayer) 
    newPlayer.Chatted:connect(function(msg, recipient) onMessaged(msg, recipient, newPlayer) end) 
end     

game.Players.ChildAdded:connect(onPlayerJoin)

Problematic section of the code:

        if msg == End and Rolling == true then
                script.RisingAction:Stop()
                h.Text = "The fortune chosen is ".. script.GamemodeName.Value.. "!"
                ms.Enabled = false
                if script.ResultNumber.Value == 1 then
                    script.PrettyGood:Play()
                elseif script.ResultNumber.Value == 2 then
                    randomfailuresound = math.random(1,3)
                    if randomfailuresound == 1 then
                        script.Bruh:Play()
                    elseif randomfailuresound == 2 then
                        script.Laugh:Play()
                    elseif randomfailuresound == 3 then
                        script.Fart:Play()
                    end
                elseif script.ResultNumber.Value == 3 then
                    script.SwordSlash:Play()
                    script.DAH:Play()
                elseif script.ResultNumber.Value == 4 then
                    script.Cash:Play()
                elseif script.ResultNumber.Value == 5 then
                    script.WAH:Play()
                elseif script.ResultNumber.Value == 6 then
                    script.Medium:Play()
                elseif script.ResultNumber.Value == 7 then
                    script["Yay!"]:Play()
                elseif script.ResultNumber.Value == 8 then
                    script["Yay!"]:Play()
                elseif script.ResultNumber.Value == 9 then
                    randomfailuresound = math.random(1,3)
                    if randomfailuresound == 1 then
                        script.Bruh:Play()
                    elseif randomfailuresound == 2 then
                        script.Laugh:Play()
                    elseif randomfailuresound == 3 then
                        script.Fart:Play()
                    end
                elseif script.ResultNumber.Value == 10 then
                    script.Highest:Play()
                end
                wait(4)
                h:Destroy()
                m:Destroy()
                game.Lighting.Blur.Enabled = false
                Rolling = false
                workspace.RollCommandBeingUsed.Value = false
            end
        end

    end
end

1 answer

Log in to vote
0
Answered by 1 year ago

Another script which was helping this script just had the wrong location inside the code.

Ad

Answer this question