So I'm trying to make my script not work if the local player's sit value is true.
the directory is: game.Players.LocalPlayer.Humanoid.Sit
when I try to do:
() if game.Players.LocalPlayer.Humanoid.Sit = true then wait (999999) end
my actual script is down here ()
my script just doesn't work anymore. I need a way to basically ask my script, is the local character sitting down and if they are, wait (9999999)
Thank you! =D
P.S. (If you're wondering, I'm new at lua)
In comparing/testing for values, we don't use a single equal sign, but a double. A single equal sign is used to assign a variable:
Assigning a variable:
1 | x = 2 |
Comparing two values:
1 | if game.Players.LocalPlayer.Humanoid.Sit = = true then |
2 | wait( 1337 ) |
3 | end |
01 | local player = game.Players.LocalPlayer |
02 |
03 | local character = workspace:WaitForChild(player.Name) |
04 |
05 | while true do |
06 | if character.Humanoid.Sit = = true then |
07 | wait( 999999 ) |
08 | else |
09 | wait() |
10 | end |
11 | end |
This is a continuous loop variant of the sit value, however, you could check it whenever the player begins to sit or with another activated event like so.
01 | local player = game.Players.LocalPlayer |
02 |
03 | local character = workspace:WaitForChild(player.Name) |
04 |
05 | character.Humanoid.Changed:Connect( function () |
06 | if character.Humanoid.Sit = = true then |
07 | wait( 999999 ) |
08 | else |
09 | wait() |
10 | end |
11 | end ) |
A single "=", as you attempted, is used to change values, while a double consecutive "==" is used to check if a value is equal to what comes after.