So basically I made a script that should tell when a player sits down. I want it to print the name of the chair they sat in. Bad news it always prints nil . So Im wondering why is this happing?
local planes = game:GetService('CollectionService'):GetTagged('Plane')
-- services
local uis = game:GetService('UserInputService')
-- player
local player =game:GetService('Players').LocalPlayer
local char = player.Character
local hum = char:FindFirstChildOfClass('Humanoid')
hum:GetPropertyChangedSignal('Sit'):Connect(function()
local chair = hum.SeatPart -- this should be the chair that they sat in
print(chair)
end)
You should check if there is chair, because maybe it has a bit of delay and doesnt know what chair is
local planes = game:GetService('CollectionService'):GetTagged('Plane')
-- services
local uis = game:GetService('UserInputService')
-- player
local player = game:GetService('Players').LocalPlayer
local char = player.Character
local hum = char:FindFirstChildOfClass('Humanoid')
hum:GetPropertyChangedSignal('Sit'):Connect(function()
local chair = hum.SeatPart -- this should be the chair that they sat in
if chair then
print(chair)
else
print("Not sitting in a chair.")
end
end)