-
What do you want to achieve? I’m making a puzzle game with a friend. For the first puzzle, there is a button to open a door, but it’s meant to close if the player steps off, so there’s a box that needs to be pushed onto the button to keep it down.
-
What is the issue? I can’t figure out how to make the button and door that the button opens start reversing, especially while they’re in the middle of activation.
-
What solutions have you tried so far? I’ve tried to script it myself and I’ve searched the DevForum, but I can’t find anything. This is the code I have right now to open the door and activate the button.
local pressed = false
local button = script.Parent
local buttonPressed = button.Parent.ButtonPressed
local TS = game:GetService("TweenService")
button.Touched:Connect(function()
if pressed == false then
pressed = true
--debounce here isnt fully needed
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local POSTween = TS:Create(button, tweenInfo, {Position = buttonPressed.Position})
local ColorTween = TS:Create(button, tweenInfo, {Color = Color3.fromRGB(77, 255, 0)})
POSTween:Play()
ColorTween:Play()
local Door1 = game.Workspace.Door1.Door
local Door1Target = game.Workspace.Door1.DoorTarget
local DoorSound = Door1.OpenSound
local StartingDoorInfo = TweenInfo.new(5.624, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local DoorTween = TS:Create(Door1, StartingDoorInfo, {Position = Door1Target.Position})
DoorTween:Play()
DoorSound:Play()
end
end)
Would appreciate any help. Thanks.