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

How do you scan if a value = false?

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)

3 comments

0

just add a boolvalue in to the player and check if its true or false

0

could you give me an example of a boolvalue with my script please?

0

May math.huge

2 answers

✓ Accepted answer

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:

x = 2

Comparing two values:

if game.Players.LocalPlayer.Humanoid.Sit == true then
	wait(1337)
end
local player = game.Players.LocalPlayer

local character = workspace:WaitForChild(player.Name)

while true do
	if character.Humanoid.Sit == true then
		wait(999999)
	else
		wait()
	end
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.

local player = game.Players.LocalPlayer

local character = workspace:WaitForChild(player.Name)

character.Humanoid.Changed:Connect(function()
	if character.Humanoid.Sit == true then
		wait(999999)
	else
		wait()
	end
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.

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