EDIT: The problem has been resolved!: Check the other answer/ comment written by myself, below.
Hey there. I was trying to get a certain seat part whenever a humanoid/ player would sit on it. So I check out the wiki: https://developer.roblox.com/en-us/api-reference/event/Humanoid/Seated
And found the "Humanoid.SeatPart", that sounded like just what I needed. But before trying out the "Humanoid.SeatPart" property, I first wanted to test the "Humanoid.Sit" property.
So I made a Local Script in the StarterPack, and a Seat object in Workspace.
This is the code that I used:
if game.Players.LocalPlayer.Character.Humanoid.Sit==true then print "Character is sitting" else print "Character is not sitting" end
The code is super simple, and I have no clue why it doesn't work...
The Output says:
" Players.henrikknudsen.Backpack.LocalScript:1: attempt to index field 'Character' (a nil value)"
Thanks in advance! :-)
Little update: I have now tried using a line of code from the Roblox Developer Hub/ Roblox Dev wiki. link: (https://developer.roblox.com/en-us/api-reference/event/Humanoid/Seated) - at the bottom of the page. (And yes, I placed the code in a Local Script and parented it to the StarterPlayer.StarterPlayerScripts).
local character = script.Parent local humanoid = character:WaitForChild("Humanoid") humanoid.Seated:Connect(function(isSeated, seat) if isSeated then if seat then print ("The player is now sitting in the seat named "..seat.Name.."!") end else print("The player is no longer sitting!") end end)
The code, despite being on the wiki, also doesn't work. Could this have been caused by some Roblox update? Or did both Roblox and I make the same mistake?
EDIT: The problem has been resolved!! :D Apparently you had to place the Local Script in "StarterPlayer.StarterCHARACTERScripts" instead of "StarterPlayer.StarterPLAYERScripts"!