I’m trying to make characters play specific animations when sitting on certain parts that are only available inside the player’s morph. Like for example, a part meant for a sitting on the floor animation will play a different sit animation from a part meant for a sitting on a chair animation.
Something else I’ve tried is making a localscript inside the player that checks for a folder with a specific name in the workspace so every time a player sits on a part in that folder the designated animation plays, but that doesn’t work.
I can guarantee I’m missing something but I’m not exactly the best scripter so I can’t figure anything out.
I have searched all over the DevForum for some sort of answer but I’ve gotten next to no answers. I’m pretty sure what I’m trying to do also isn’t something that someone normally tries without already knowing how to do it.
Here’s the full script from the localscript within the player:
—Script—
local floorsit = script:WaitForChild(“FloorSit”)
local benchsit = script:WaitForChild(“BenchSit”)
local humanoid = script.Parent:FindFirstChild(“Humanoid”)
local animTrack1 = humanoid.Animator:LoadAnimation(floorsit)
local animTrack2 = humanoid.Animator:LoadAnimation(benchsit)
local function FloorSit()
for _, possiblePart in pairs(workspace.FloorSeats:GetChildren()) do
humanoid:GetPropertyChangedSignal(“Sit”):Connect(function()
if possiblePart:IsA(“BasePart”) then
if humanoid.Sit == true then
animTrack1:Play()
else
animTrack1:Stop()
end
end
end)
end
end
If anyone is able/willing to help I’d be most grateful, thank you!
I think it would be able to help if I knew exactly how to structure this sort of thing in a script. It’s more advanced then what I’m used to doing so I’m not exactly sure what to do here. If you’re able to help with a script layout then I’d be most appreciative.
So, inside of your floorsit function, you would do Humanoid:GetPropertyChangedSignal("SeatPart"):Connect(function())
to get an event whenever the seatpart changes.
Then, you check if the seatpart exists or not
if Humanoid.SeatPart then
If it exists, then check if it’s parent is workspace.FloorSeats
If Humanoid.SeatPart.Parent == workspace.FloorSeats then
If that passes, then play your animation.
now, if the Humanoid.SeatPart == nil then, you would stop the animation. Hope that helped.
Thanks for the help so far, it still doesn’t work as of now so I may have typed the script part wrong. Any advice?
local function FloorSit()
humanoid:GetPropertyChangedSignal(“SeatPart”):Connect(function()
if humanoid.SeatPart then
if humanoid.SeatPart.Parent == workspace.FloorSeats then
animTrack1:Play()
if humanoid.SeatPart.Parent == nil then
animTrack1:Stop()
end
end
end
end)
end
Also my humanoid uses a lowercase capital so no that wouldn’t be the issue. Thanks!
local floorsit = script:WaitForChild(“FloorSit”)
local benchsit = script:WaitForChild(“BenchSit”)
local humanoid = script.Parent:FindFirstChild(“Humanoid”)
local animTrack1 = humanoid.Animator:LoadAnimation(floorsit)
local animTrack2 = humanoid.Animator:LoadAnimation(benchsit)
local function FloorSit()
humanoid:GetPropertyChangedSignal(“SeatPart”):Connect(function()
if humanoid.SeatPart then
if humanoid.SeatPart.Parent == workspace.FloorSeats then
animTrack1:Play()
else
animTrack1:Stop()
end
end
end)
end
IT WORKS! Only issue is that sometimes between animations the character seems to try playing the sit animation again, at least until you sit on a different part. It’s not a big deal though. If you have any suggestions for a way to fix that though then thank you for time and patience with me!
Under the character, theres a script called “Animate” this script can be disabled to remove all default animations, or the Ids underneath it can be modified to make custom animations
It’s a custom animation set, it just tries playing the animation from that seat part, since it fixes itself when sitting on a different part, which as of now doesn’t have an animation assigned to it meaning there is no animation to play.
Hopefully the video shows it well. You can see before sitting there’s no issues, but after sitting, the character tries to play a sit animation between doing animations. So I don’t think the animation stop part of the script is exactly working.
No see, between animations after sitting, it tries to play the sit animation before playing the correct animation, meaning the sit animation would be trying to play in the background. Which means the animtrack1:Stop() isn’t working properly.
local floorsit = script:WaitForChild(“FloorSit”)
local benchsit = script:WaitForChild(“BenchSit”)
local humanoid = script.Parent:FindFirstChild(“Humanoid”)
local animTrack1 = humanoid.Animator:LoadAnimation(floorsit)
local animTrack2 = humanoid.Animator:LoadAnimation(benchsit)
local function FloorSit()
humanoid:GetPropertyChangedSignal(“SeatPart”):Connect(function()
if humanoid.SeatPart then
if humanoid.SeatPart.Parent == workspace.FloorSeats then
animTrack1:Play()
end
else
animTrack1:Stop()
end
end)
end