Simple as the title, the If-Statement is not proceeding when all the expressions are true. I'm trying to see if the player is sitting and the parent of the seat that the player is sitting in is called "Bed". Not sure why it is not firing.
More info: Already made sure that the model of the seat is actually "Bed" (using print), and the if statement does fire when the player is seated (Without the 2nd expression), it's just when I added the second expression, it's not firing.
More Details: The script is in a LocalScript in StarterGui, just tried using game.Players.LocalPlayer.Character with no luck. Also, this is just a snippet of the actual code, I do have an average knowledge of lua, so there aren't any basic errors (like missing an end). Updated script below.
if game.Players.LocalPlayer.Character.Humanoid.Sit == true and game.Players.LocalPlayer.Character.SeatPart.Parent.Name == "Bed" then game.Workspace.Values.NumInBed.Value = workspace.Values.NumInBed.Value + 1 script.Parent.Parent.Character.Humanoid.JumpPower = 0
I'm not 100% sure what you're trying to do. I also recommend to not change values on the client side, try the server side using RemoteEvents, ServerScripts, and LocalScripts.
But, I think this is somewhat of what you're trying to do?
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local ws = game:GetService("Workspace") if humanoid.Sit == true and humanoid.SeatPart.Parent.Name == "Bed" then ws.Values.NumInBed.Value = ws.Values.NumInBed.Value + 1 humanoid.JumpPower = 0 end