I have made a script, And everything checks out, no errors. But it dosen’t work, the event dosen’t even fire.
local human = game.Players.LocalPlayer.Character.Humamoid
human.Changed:Connect(function()
if human.Sit == true then
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
else
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
end
end)
Notice: This is in a localscript, In StarterPlayerScripts
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Seated then
print("Humanoid seated!")
elseif oldState == Enum.HumanoidStateType.Seated then
print("Humanoid no longer seated!")
end
end)
I’d consider using the “.StateChanged” event instead for this as it’ll only fire when the character’s humanoid’s state changes, additionally you receive the old state and the new state as arguments to any callback function connected to the event via the RBXScriptSignal instance method “:Connect()”. The code snippet above is a local script and it should be placed inside the StarterCharacterScripts folder.