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
3 years ago
Edited 3 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()

01if script.Parent.Text == "Run" then
02 
03    if script.Parent.Text == "Walk(3)" or "Walk(2)" or "Walk(1)" and script.Parent.BackgroundColor3 == Color3.fromRGB(255, 0, 0) then
04 
05        script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 16
06        script.Parent.Text = "Run"
07 
08    end
09    script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 32
10    script.Parent.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
11    script.Parent.Text = "Walk"
12    wait(1)
13    script.Parent.Text = "Walk(3)"
14    wait(1)
15    script.Parent.Text = "Walk(2)"
View all 27 lines...

end)

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

2 answers

Log in to vote
0
Answered by
sncky -20
3 years ago
01function run()
02    if script.Parent.Text == "Run"
03    then script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 35
04        script.Parent.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
05        script.Parent.Text = "Walk"
06    elseif script.Parent.Text == "Walk"
07    then script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 16
08        script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
09        script.Parent.Text = "Run"
10    end
11end
12 
13script.Parent.MouseButton1Click:connect(run)
Ad
Log in to vote
0
Answered by 3 years ago

Try this:

01script.Parent.MouseButton1Click:Connect(function()
02if script.Parent.Text == "Run" then
03 
04    if script.Parent.Text == "Walk(3)" or "Walk(2)" or "Walk(1)" and script.Parent.BackgroundColor3 == Color3.fromRGB(255, 0, 0) then
05 
06        script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 16
07        script.Parent.Text = "Run"
08 
09        end
10    end
11    script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 32
12    script.Parent.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
13    script.Parent.Text = "Walk"
14    wait(1)
15    script.Parent.Text = "Walk(3)"
View all 28 lines...

Answer this question