I am making an elevator, and when the player gets in, he gets welded to the floor. But when he gets welded to the floor the walking animations starts playing (because he walked in the elevator and when he touches the floor he gets welded)
Full code:
local TS = game:GetService("TweenService")
local part = script.Parent:WaitForChild("Floor")
local standPos = script.Parent:WaitForChild("StandPos")
local open = false
local function autoOpen()
while true do
wait(5)
open = true
wait(3)
open = false
end
end
spawn(autoOpen)
local tweenInfo = TweenInfo.new(
5,
Enum.EasingStyle.Quint,
Enum.EasingDirection.Out,
-1,
true,
3
)
local goal = {CFrame = CFrame.new(17, 17.5, 18.5)}
local tween = TS:Create(part, tweenInfo, goal)
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and open then
local human = hit.Parent.Humanoid
local weld = Instance.new("WeldConstraint")
local rootPart = hit.Parent.HumanoidRootPart
hit.Parent.Animate.Disabled = true
wait()
local AnimationTracks = human:GetPlayingAnimationTracks()
for i,v in pairs(AnimationTracks) do
v:Stop()
end
rootPart.Position = standPos.Position
weld.Parent = rootPart
weld.Part0 = rootPart
weld.Part1 = part
wait(5)
hit.Parent.Animate.Disabled = false
weld:Destroy()
wait(2.5)
end
end)
tween:Play()
Important code:
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and open then
local human = hit.Parent.Humanoid
local weld = Instance.new("WeldConstraint")
local rootPart = hit.Parent.HumanoidRootPart
hit.Parent.Animate.Disabled = true
wait()
local AnimationTracks = human:GetPlayingAnimationTracks()
for i,v in pairs(AnimationTracks) do
v:Stop()
end
rootPart.Position = standPos.Position
weld.Parent = rootPart
weld.Part0 = rootPart
weld.Part1 = part
wait(5)
hit.Parent.Animate.Disabled = false
weld:Destroy()
wait(2.5)
end
end)
~~~~~~~~~~~~~~~~~[]
Things I have tried: [this](https://developer.roblox.com/en-us/api-reference/function/Humanoid/GetPlayingAnimationTracks)
(you can see it in the code)
and also [this](https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstleyVEVO)
