Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

attempt to index nil with 'CFrame'?

Asked by 3 years ago

I've been trying to make an animated door with Tween Service or whatever you call it but I continue to get the same error: ServerScriptService.Script:9: attempt to index nil with 'CFrame' 

local TweenService = game:GetService("TweenService")

local door = workspace.Door
local DoorRoot = door.PrimaryPart

local DoorSwingInfo = TweenInfo.new()

local DoorSwingTween = TweenService:Create(doorRoot, DoorSwingInfo, {
    CFrame = doorRoot.CFrame * CFrame.Angles(0, math.rad(95), 0)
})

wait(5)
DoorSwingTween:Play()
0
You defined local DoorRoot then tried to set the cframe of doorRoot. Capitalization matters. WizyTheNinja 834 — 3y
0
I corrected the mistake and I'm still experiencing the same error. ParaXero 14 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Try this

local TweenService = game:GetService("TweenService")

local door = workspace.Door
local DoorRoot = door.PrimaryPart

local DoorSwingInfo = TweenInfo.new()
local goal = {}
goal.CFrame = DoorRoot.CFrame * CFrame.Angles(0, math.rad(95), 0)
local DoorSwingTween = TweenService:Create(DoorRoot, DoorSwingInfo, goal)

wait(5)
DoorSwingTween:Play()
Ad

Answer this question