What do you want to achieve?
I’m trying to play an animation when the player is sitting, and I’d like to make sure that it works on R6 and R15.
What is the issue?
I don’t know how to detect if the player is using R6 or R15 in a seat.
What solutions have you tried so far?
I tried to follow the method from this topic by detecting the seat.Occupant’s torso.
seat = script.Parent
local human
function added(child)
human = seat.Occupant
if human ~= nil then
if seat.Occupant.Parent.Torso then
anim = human:LoadAnimation(seat.SitAnimR6)
anim:Play()
end
if seat.Occupant.Parent.UpperTorso then
anim = human:LoadAnimation(seat.SitAnimR15)
anim:Play()
end
end
end
function removed(child2)
if anim ~= nil then
anim:Stop()
anim:Remove()
end
end
seat.ChildAdded:connect(added)
seat.ChildRemoved:connect(removed)
Am I doing this right? Because the animation didn’t play at all.
seat = script.Parent
local human
function added(child)
human = seat.Occupant
if human ~= nil then
if human.RigType == "R6" then
anim = human:LoadAnimation(seat.SitAnimR6)
anim:Play()
else
anim = human:LoadAnimation(seat.SitAnimR15)
anim:Play()
end
end
end
seat = script.Parent
local human
function added(child)
human = seat.Occupant.Humanoid
if human ~= nil then
if human.RigType == "R6" then
anim = human:LoadAnimation(seat.SitAnimR6)
anim:Play()
else
anim = human:LoadAnimation(seat.SitAnimR15)
anim:Play()
end
end
end
nvm, I fixed it.
I’ll just put the block of code here for the others who don’t know how to do so…
seat = script.Parent
local human
function added(child)
human = seat.Occupant
if human ~= nil then
if seat.Occupant.RigType.Name == "R6" then
anim = human:LoadAnimation(seat.SitAnimR6)
anim:Play()
else
anim = human:LoadAnimation(seat.SitAnimR15)
anim:Play()
end
end
end
function removed(child2)
if anim ~= nil then
anim:Stop()
anim:Remove()
end
end
seat.ChildAdded:connect(added)
seat.ChildRemoved:connect(removed)