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

What is wrong with this script?

Hi, Is just that I'm making this sprint but something is wrong with the debounce and I don't know how to fix it, everything else is okey since the Output shows no errors.

The idea is for the "Repeat" loop to stop subtracting the value 1 to SoulPoints if the Debounce SF becomes true or if SoulPoints reaches 0, It stops once the value is 0 but not when SF equals true. This might be a total beginner error but please help me.

Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
ST = false
SF = false

function Sprint(key)
	Key = key:lower()
	
	if Key == Skills["Sprint"].HotKey.Text and ST == false and SF == false and SoulPoints.Value >= 1 then
		ST = true
		
		Hum.WalkSpeed = 50
		
		repeat
		SoulPoints.Value = SoulPoints.Value - 1
		wait()
		until
		SF == true or SoulPoints.Value == 0
	end
end

function SprintStop(key)
	Key = key:lower()
	
	if Key == Skills["Sprint"].HotKey.Text and ST == true and SF == false then
		ST = false
		SF = true
		
		Hum.WalkSpeed = 16
	end
	SF = false
end

Mouse.KeyDown:connect(Sprint)
Mouse.KeyUp:connect(SprintStop)

2 answers

On lines 27-31. Notice how you set SF to true, but not even within a frame, you're setting it back to false. The repeat loop has almost no time to catch the change. Instead of having SF=false on line 31, put it below line 18.

1 comment

0

Yes, Thank you so much, it worked.

you forgot ~~~~~~~~~~~~~~~~~ end

i think

2 comments

0

i mean "end"

0

No... That's just plain... I mean no, if I where missing an end, the output would have told me.

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