Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

attempt to index nil with 'CFrame'?

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()

2 comments

0

You defined local DoorRoot then tried to set the cframe of doorRoot. Capitalization matters.

0

I corrected the mistake and I'm still experiencing the same error.

1 answer

✓ Accepted answer

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()

This discussion is preserved as it was. New answers, comments, and votes are closed.