script.Parent.primary.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
script.Parent.PrimaryPart = script.Parent.primary
local primary = script.Parent.PrimaryPart
local model = script.Parent
local targetPosition = primary.CFrame + Vector3.new(0,10,0)
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(7, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, true)
local goal = {}
goal.CFrame = targetPosition
local tween = ts:Create(primary, ti, goal)
tween:Play()
--sound
local sound = script.Parent["Large Door Open [2]"]
sound.Pitch = 0.7
if sound.IsPlaying then
return
else
sound:Play()
end
end
end)
hi, the script I'm making is for a door open animation, once the player touches the door the animation starts playing. but if the player touches the door while the tween is playing, the door gets bugged and it doesn't close fully. I've tried patching it by integrating
if tween.PlaybackState == Enum.PlaybBackState.Playing then
wait()
end
into it but that didn't work. if anyone knows a fix, it would be greatly appreciated.
(Basically I need the script to wait until the tween is finished, then another tween can be played)
** You are now Level 2! **