im having a problem where my value is setting to true but my code doesnt run,
01 | local SuperSpeed = script:WaitForChild( "SuperSpeed" ) |
02 | local Fast = script:WaitForChild( "Fast" ) |
03 | local Intermediate = script:WaitForChild( "Intermediate" ) |
04 | local Slow = script:WaitForChild( "Slow" ) |
05 | local CharacterSpeed = script:WaitForChild( "CharacterSpeed" ) |
06 |
07 | if SuperSpeed.Value = = true then |
08 | print ( "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" ) |
09 | game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 157 |
10 | CharacterSpeed.Value = 157 |
i have a separate GUI to set the SuperSpeed Value to True, and it is setting it. but none of the code for the Value being true is being run,
The problem is that the statement checks if the value is true before the value was even set to true. In order to prevent this, you can use the Changed
event.
01 | local SuperSpeed = script:WaitForChild( "SuperSpeed" ) |
02 | local Fast = script:WaitForChild( "Fast" ) |
03 | local Intermediate = script:WaitForChild( "Intermediate" ) |
04 | local Slow = script:WaitForChild( "Slow" ) |
05 | local CharacterSpeed = script:WaitForChild( "CharacterSpeed" ) |
06 |
07 | SuperSpeed.Changed:Connect( function () |
08 | if SuperSpeed.Value = = true then |
09 | print ( "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" ) |
10 | game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 157 |
11 | CharacterSpeed.Value = 157 |
12 | end |
13 | end ) |
1 | local BoolValue = Instance.new( "BoolValue" ) |
2 | BoolValue.Parent = script |
3 | BoolValue.Value = true |
4 |
5 | if BoolValue.Value then |
6 | print ( 'ebic!' ) |
7 | end |
I hope this helps out.