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

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

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

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)


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)

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