Hello, I'm trying to make animated doors with if command. I get this error, no clue what's wrong. Anyone know how to fix this?
local lockdownyesno = script.Parent.Parent.Lockdown local tween = game:GetService("TweenService") local center = script.Parent.Parent.Parent.Center local Door = "Closed" local CF = Instance.new("CFrameValue") CF.Value = center.CFrame CF.Changed:Connect(function() center.CFrame = CF.Value end) local debounce = true if debounce then debounce = false script.Parent.Parent.Parent.Parent.Touched:Connect(function() if lockdownyesno.Value == 1 then debounce = true if Door == "closed" then tween:Create(CF, TweenInfo.new(1, Enum.EasingStyle.Quart), {Value = center.CFrame * CFrame.Angles(math.rad(0),math.rad(90),math.rad(0))}):play() Door = "open" elseif tween:Create(CF, TweenInfo.new(1, Enum.EasingStyle.Quart), {Value = center.CFrame * CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0))}):play() then Door = "closed" end wait(1) debounce = false end end ) end
Error: Center is not a valid member of Workspace
Workspace: https://gyazo.com/e13942fbe3cd28c3d11c49cb4efc35d8
local center = script.Parent.Parent.Parent.Center
is going to workspace, you want to go to the door model, so you could use local center = script.Parent.Center
The issue appears to be with the variable. Try something like this:
local center = script.Parent.Parent.Center
With the extra .Parent added into there that means its trying to find it in workspace, and not the folder.