I’m trying to make a door tween open using this code:
local TweenService = game:GetService("TweenService")
local door = script.Parent
local doorHinge = door.PrimaryPart
local doorOpen = TweenInfo.new()
local doorCFrame = TweenService:Create(doorHinge, doorOpen, {
CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(-100),0)
})
local doorCFrameClosed TweenService:Create(doorHinge, doorOpen, {
CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(0), 0)
})
local ClickDetection = script.Parent.ClickDoor.ClickDetector
ClickDetection.MouseClick:Connect(function()
doorCFrame:Play()
ClickDetection.MaxActivationDistance = 0
script.Parent.Open:Play()
wait(3)
doorCFrameClosed:Play()
ClickDetection.MaxActivationDistance = 24
wait(1)
script.Parent.Close:Play()
end)
When I run the script, the door noise plays but the door does not open, and the output logs me this error “Workspace.Door.Script:21: attempt to index nil with ‘Play’”
Looking at the actual script, where I write doorHinge.CFrame, it doesn’t seem to be registering CFrame as a property that I can edit, I don’t know how to fix this, all help is appreciated!
Now when I run the script in game there is no error in the output, the sound and sequencing work fine, as well as the click stopper, however the door itself doesnt move and i cannot pass through
Alright, if it helps anymore I’ve recorded a video of what is happening,
local door = script.Parent
local doorHinge = door.PrimaryPart
local doorOpen = TweenInfo.new()
local doorCFrame = TweenService:Create(doorHinge, doorOpen, {
CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(-100),0)
})
local doorCFrameClosed = TweenService:Create(doorHinge, doorOpen, {
CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(0), 0)
})
local ClickDetection = door.ClickDetector
ClickDetection.MouseClick:Connect(function()
ClickDetection.MaxActivationDistance = 0
doorCFrame:Play()
door.Open:Play()
wait(3)
doorCFrameClosed:Play()
wait(1)
door.Close:Play()
ClickDetection.MaxActivationDistance = 24
end)```
Here is the script I am using, If this helps anything more than that's great.
This is a step in the right direction, although now the sound no longer works and it supplies me with this error at the doorCFrame on line 7 and I’d assume the doorCFrameClose variable too.
Workspace.Door.Script:7: attempt to index nil with ‘CFrame’ - Server - Script:7