Attempt index to nil with cframe. how to fix in this script?

local info = TweenInfo.new(2, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)
local bezig = false
local cframe = Instance.new("CFrameValue")
local cab = script.Parent.Parent.cabine
local een = cab.PrimaryPart.Cframe --nil
print(een)
local twee = cab.PrimaryPart.CFrame --nil
local verdieping = 1
function deuren(beweging)
	wait()
	local rechterdeur = game:GetService("TweenService"):Create(script.Parent.cabine.Partr, info, {Position = 
		script.Parent.Parent.cabine.Partr.Position - (beweging)*script.Parent.Parent.cabine.Partr.CFrame.LookVector * 5})
	local linkerdeur = game:GetService("TweenService"):Create(script.Parent.cabine.Partl, info, {Position = 
		script.Parent.Parent.cabine.Partl.Position + (beweging)*script.Parent.Parent.cabine.Partl.CFrame.LookVector * 5})
	rechterdeur:Play()
	linkerdeur:Play()
	linkerdeur.Completed:Wait()
	wait()
end

function omhoog(functie)
	bezig = true
	deuren(-1)
	wait(1)
	cframe.Value = script.Parent.cabine:GetPrimaryPartCFrame()
	cframe:GetPropertyChangedSignal("Value"):Connect(function()
		cab:SetPrimaryPartCFrame(CFrame.Value)
	end)
	local func = TweenInfo.new(4)
	local beweging3 = game:GetService("TweenService"):Create(cframe, func, { Value = functie })
	beweging3:Play()
	beweging3.Completed:Wait()
	deuren(1)
	bezig = false
end

script.Parent.cabine.liftknop.ClickDetector.MouseClick:Connect(function()
print(een)
	if bezig ~= true then
		if verdieping == 1 then
		omhoog(twee)
			verdieping = 2
		end
	end
end)

script.Parent.cabine.liftknop3.ClickDetector.MouseClick:Connect(function()
	deuren(1)
end)

What line is the error on? chars chars

The only places I see you trying to get the CFrame property is when you try to get cab's PrimaryPart, which means that you didn’t put a PrimaryPart for it, so the solution would be to give it one

sorry I think I solved it in properties

yes, I think you’re right ------bc otherwise its to short

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.