Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to force player to be seated?

Asked by 5 years ago
Edited 5 years ago

I am trying to make a script that will force the player to be seated during a cutscene, but the script I am using does not work?

01-- Roblox services
02local Workspace = game:GetService("Workspace")
03 
04-- Variables
05local seat = script.Parent
06local Classroom3 = seat.Parent.Parent
07local seatOccupant = seat.Occupant
08local CutscenePlayed = Classroom3:WaitForChild("CutscenePlayed")
09local CutsceneScript = Classroom3:WaitForChild("cutsceneScript")
10 
11print("Test 1")
12 
13local function startCutscene()
14 
15    print("Test 2")
View all 31 lines...

When I run this code, I get this error message: Attempt to index nil with 'Sit'

I don't really understand the error message. I know what nil is, but indexing?

All help will be appreciated greatly!

EDIT: I tried to print seatOccupant, but it printed nil.

0
Put in a server script: Humanoid:Sit(*insert seat here*) torchmaster101 92 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

Your missing something very simple. The character doesn't have a sit value. The Humanoid has a sit value

Ad
Log in to vote
0
Answered by 5 years ago

Try this

01-- Roblox services
02local Workspace = game:GetService("Workspace")
03 
04-- Variables
05local seat = script.Parent
06local Classroom3 = seat.Parent.Parent
07local seatOccupant = seat.Occupant
08local CutscenePlayed = Classroom3:WaitForChild("CutscenePlayed")
09local CutsceneScript = Classroom3:WaitForChild("cutsceneScript")
10 
11print("Test 1")
12 
13local function startCutscene()
14 
15    print("Test 2")
View all 31 lines...

this is assuming that seat is some sort of a seat instead of a normal part

Answer this question