Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you scan if a value = false?

Asked by 5 years ago

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)

0
just add a boolvalue in to the player and check if its true or false DesiredRep 75 — 5y
0
could you give me an example of a boolvalue with my script please? nickos3 4 — 5y
0
May math.huge Ziffixture 6913 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
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.

Answer this question