What do you want to achieve? Keep it simple and clear!
I want to make a check that detects when someone sits
What is the issue? Include screenshots / videos if possible!
It was working for a while, but suddenly stopped
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I found nobody else with the issue
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
while task.wait(0.1) do
if hum.Sit == true then
print("sitting")
end
end
it might be that you are on the client and not the server, try switching to serverscript and making the code this:
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
while task.wait(0.1) do
if hum.Sit == true then
print("sitting")
end
end
end)
--// Local script
local Player = game:GetService('Players').LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild('Humanoid') ::Humanoid
local function ValueChanged()
if Humanoid.Sit then
print('sitting')
end
end
Humanoid:GetPropertyChangedSignal('Sit'):Connect(ValueChanged)
Whats the actual goal besides just detect if they sit? Why do you need to detect it? Just asking incase it needs to be local or server or a different method of detecting if they’re sitting, OnSeated event or PropertyChangedSignal
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid", 5)
hum:GetPropertyChangedSignal("Sit"):Connect(function()
if hum.Sit == true then
print("sitting")-- your code here if player is sitting
else
print("not sitting")-- your code here if player is not sitting
end
end)
local players = game:GetService("Players")
local player = players.LocalPlayer or players:GetPropertyChangedSignal("LocalPlayer"):Wait()
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local function onSeated(onSeat, seatPart)
if onSeat and seatPart then
print("sit action")
else
print("NO! >:( please go sit again and relax for the day")
end
end
humanoid.Seated:Connect(onSeated)