I was scripting an elevator door and then suddenly I come up with an issue.
So, every time the player presses a button the door close tween will play. However, it didn’t!
I tried using print() and it prints upon pressing the button but the tween doesn’t play!
Script
local TweenService = game:GetService("TweenService")
local TweenSettings = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local CloseDoorTween1 = TweenService:Create(script.Parent.Parent.Parent.Parent.Parent.Parent.Door1, TweenSettings, {CFrame = CFrame.new(script.Parent.Parent.Parent.Parent.Parent.Parent.Door1.Position + Vector3.new(1.5,0,1.5))})
script.Parent.ClickDetector.MouseClick:Connect(function(playerWhoClicked)
print("Button clicked!")
CloseDoorTween1:Play()
end)
The tween settings are for 2D user interface only, you can’t add modifiers on 3D objects.
local TweenService = game:GetService("TweenService")
local TweenTime = TweenInfo.new(1)
local Door = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Door1" ,5)
local Click = script.Parent:WaitForChild("ClickDetector" ,5)
if Door ~= nil and Click ~= nil then
Click.MouseClick:Connect(function(Player)
local Goal = {}
Goal.Position = Vector3.new(Door.Position.X + 1.5, Door.Position.Y, Door.Position.Z + 1.5)
local Tween = TweenService:Create(Door, TweenTime, Goal)
Tween:Play()
end)
end