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

My run and walk GUI script is not working even though I think it should work?

Asked by
2mania 14
2 years ago
Edited 2 years ago

So I was testing a script I was making that was about running and walking and when you press the run button it will say walk then a countdown and then it will put you back to normal speed but if you press the button while the countdown is counting down it will keep counting but will change the walk speed to normal. I tried fixing it but it didn't work.

Here is the script if you wanna help me. ~~~~~~~~~~~~~~~~~

script.Parent.MouseButton1Click:Connect(function()

if script.Parent.Text == "Run" then

    if script.Parent.Text == "Walk(3)" or "Walk(2)" or "Walk(1)" and script.Parent.BackgroundColor3 == Color3.fromRGB(255, 0, 0) then

        script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 16
        script.Parent.Text = "Run"

    end
    script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 32
    script.Parent.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
    script.Parent.Text = "Walk"
    wait(1)
    script.Parent.Text = "Walk(3)"
    wait(1)
    script.Parent.Text = "Walk(2)"
    wait(1)
    script.Parent.Text = "Walk(1)"
    wait(1)
    script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 16
    script.Parent.Text = "Run"
    script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)

else
    script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
    script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 16
    script.Parent.Text = "Run"
end

end)

~~~~~~~~~~~~~~~~~

2 answers

Log in to vote
0
Answered by
sncky -20
2 years ago
function run()
    if script.Parent.Text == "Run"
    then script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 35
        script.Parent.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
        script.Parent.Text = "Walk"
    elseif script.Parent.Text == "Walk"
    then script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 16
        script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
        script.Parent.Text = "Run"
    end
end

script.Parent.MouseButton1Click:connect(run)


Ad
Log in to vote
0
Answered by 2 years ago

Try this:

script.Parent.MouseButton1Click:Connect(function()
if script.Parent.Text == "Run" then

    if script.Parent.Text == "Walk(3)" or "Walk(2)" or "Walk(1)" and script.Parent.BackgroundColor3 == Color3.fromRGB(255, 0, 0) then

        script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 16
        script.Parent.Text = "Run"

        end
    end
    script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 32
    script.Parent.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
    script.Parent.Text = "Walk"
    wait(1)
    script.Parent.Text = "Walk(3)"
    wait(1)
    script.Parent.Text = "Walk(2)"
    wait(1)
    script.Parent.Text = "Walk(1)"
    wait(1)
    script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 16
    script.Parent.Text = "Run"
    script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)

    script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
    script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 16
    script.Parent.Text = "Run"
end)

Answer this question