Tweening won't work when inside a vehicle model

I’ve made a door on the back of a vehicle that i want to open when the player clicks the ClickDetector within it, as seen below it works perfectly fine outside a vehicle. But when it’s a child of the vehicle it simply does nothing, not producing any errors in output in addition to that.

(Working Example outside vehicle model)

(When inside the vehicle model)

Here is my script i’m using:

local TweenService = game:GetService("TweenService")

--moving objects
local MoveDoor = script.Parent.Parent
local MoveHandle = script.Parent.Parent.Parent.MoveHandle
-- open
local OpenDoor = script.Parent.Parent.Parent.OpenDoor
local OpenHandle = script.Parent.Parent.Parent.OpenHandle
-- close
local CloseDoor = script.Parent.Parent.Parent.CloseDoor
local CloseHandle = script.Parent.Parent.Parent.CloseHandle

local TweenInformation = TweenInfo.new(

5, --length
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false
)

local OpenedMainDoor = {
	CFrame = OpenDoor.CFrame 

}
local OpenedHandle = {
	CFrame = OpenHandle.CFrame

}



local ClosedDoor = {
	
	CFrame = CloseDoor.CFrame
}

local ClosedHandle = {
	CFrame = CloseHandle.CFrame
}

local enabled = false
function TweenDoor()
	if enabled == false then
		enabled = true
		local CT = TweenService:Create(MoveDoor,TweenInformation,OpenedMainDoor)
		CT:Play()
		
	    local CHT = TweenService:Create(MoveHandle,TweenInformation,OpenedHandle)
		CHT:Play()
		
		
	elseif enabled == true then
		
		enabled = false
		local Tween = TweenService:Create(MoveDoor,TweenInformation,ClosedDoor)
		     Tween:Play()
		local Tween2 = TweenService:Create(MoveHandle,TweenInformation,ClosedHandle)
		     Tween2:Play()
		
	end
	end

MoveDoor.ClickDetector.MouseClick:Connect(TweenDoor)

Because the part is welded to the car (normally). You’ll need to remove that weld and use a hinge, you’ll have to change it a bit but you will get close results.

1 Like