Help with SeatPart | Roblox Forum
Welcome to the Forums!
Join thousands of other Roblox members with a free account.
Create Forum Account

Help with SeatPart

  • This website was created by Roblox members to replace the official forums because Roblox shut them down! Join our community if you like to talk about Roblox!

Volatile

New Member
Jul 22, 2020
3
0
1
Roblox
Volatile
local seat = game.Workspace.Test

local function Test(otherPart)

local Humanoid = otherPart.parent:FindFirstChild("Humanoid")

print(Humanoid.Parent)

print(Humanoid.SeatPart)

if Humanoid.SeatPart == "Test" then

print("it worked")

end

end

seat.touched:Connect(Test)

This will print the Humanoid.part name but this hangs on the If statement check if it matches Test. what is the issue here?
 

WizardOfHills

Active Member
Jul 21, 2018
579
113
43
Roblox
WizardOfHills
Docs are here. SeatPart is an Instance, not a name / string.

Also I would not expect seat to capture the character so instantaneously that in callback to Touched it will be already seated. You may wish to add wait(0.1).
 
  • Like
Reactions: Volatile

Volatile

New Member
Jul 22, 2020
3
0
1
Roblox
Volatile
Hi WizardOfHills,

So is there any way to accomplish this? I need to validate that SeatPart is a certain name when humanoid is sitting in it.
 

CallMeKY

Moderator
Ultra
Feb 25, 2018
1,151
280
83
Maine, USA
Roblox
CallMeKY
Discord
CallMeKY#5012
local seat = game.Workspace.Test

local function Test(otherPart)

local Humanoid = otherPart.parent:FindFirstChild("Humanoid")

print(Humanoid.Parent)

print(Humanoid.SeatPart)

if Humanoid.SeatPart == "Test" then

print("it worked")

end

end

seat.touched:Connect(Test)

This will print the Humanoid.part name but this hangs on the If statement check if it matches Test. what is the issue here?
So is there any way to accomplish this? I need to validate that SeatPart is a certain name when humanoid is sitting in it.

When a player sits in a seat, the Occupant property changes. You can connect to that property with GetPropertyChangedSignal. You can get the name of the seat with Seat.Name or tostring(Seat).
Code:
local seat = workspace:WaitForChild('Test')

seat:GetPropertyChangedSignal('Occupant'):Connect(function() -- connect to this to fire every time the property changes
    if not seat.Occupant then return end -- if there is no occupant, the property will be nil
    print(seat.ClassName .. ' "' .. tostring(seat) .. '" is occupied by ' .. tostring(seat.Occupant.Parent)) -- the occupant property will be the humanoid
end)
 

Volatile

New Member
Jul 22, 2020
3
0
1
Roblox
Volatile
Thanks for the help Guys.

I think the .Name has solved it. I swear I tried that.

Code:
local seat = Humanoid.SeatPart

print (seat.Name)

    if seat.Name == "Test" then
 
General
Help Users
    SleepyWinq SleepyWinq: Oh I see,