My model hierarchy looks like this:
1. Core
2. Union
2. (Other parts I want to tween with the door)
2. Button
3. (Inside the button) Click detector
3. (Inside the button) Local script
OR
An image so it's easier to read enter image description here
local button = script.Parent
local parentPart = button.Parent -- Assuming the parent part contains all the parts you want to move together
local startPosition = parentPart.Position -- Set the starting position of the parent part
local endPosition = Vector3.new(0, 5, 0) -- Replace with the desired end position
local TweenService = game:GetService("TweenService")
local function onButtonClicked()
local tweenInfo = TweenInfo.new(
2, -- Duration of the tween in seconds
Enum.EasingStyle.Quad, -- Easing style (you can change this to other styles)
Enum.EasingDirection.Out
)
local tween = TweenService:Create(parentPart, tweenInfo, {Position = endPosition})
tween:Play()
end
button.MouseClick:Connect(onButtonClicked)
I used the previous code and clicked the button. I expected the model to move upwards, to the point I specified.
I clicked it but nothing occured
Does your button part contain a click detector?