local tweenInfo = TweenInfo.new(
2, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
true, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)```
-- locals
```local Part = script.Parent.Parent.elevatorpart -- the elevator
local tween1 = TweenService:Create(Part, tweenInfo, {Position = Vector3.new(114.377, 22.635, -16.449)}) -- the position for the elevator
local button = script.Parent -- the button
local EMbutton = script.Parent.Parent.emergencybutton -- the emergency button```
-- the scripts
```button.ClickDetector.MouseClick:Connect(function() -- click detector
tween1:Play() -- the tween plays
if EMbutton.ClickDetector.MouseClick then -- if the player clicks the emergency button then the next function fires.
if Part.Position == (114.377, 22.635, -16.449) then -- the elevators starting position
tween1:Pause() -- the tween pauses
wait (0)
tween1:Play()
if Part.Position == (114.377, 1.815, -16.449) then -- if the part is at the start then the tween will stop
tween1:Cancel()
end
wait(1)
end
wait(1)
end
end)```
the whole script wont work
button.ClickDetector.MouseClick:Connect(function()
tween1:Play()
if EMbutton.ClickDetector.MouseClick then
if Part.Position == (114.377, 22.635, -16.449) then
tween1:Pause()
wait (0)
tween1:Play()
if Part.Position == (114.377, 1.815, -16.449) then
tween1:Cancel()
end
wait(1)
end
wait(1)
end
end)
There is a ClickDetector located directly inside of the elevator button
If the above is all correct, I’m not sure what else could be the issue.
Can I have an image of the output when you run the code? Are there any errors? I would be able to pinpoint the problem much better if you were to provide me this.