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

Center is not a valid member of Workspace - How to fix this?

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

2 answers

✓ Accepted answer

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

2 comments

0

Thanks! That's work. But now there is error " 17:01:59.217 - Touched is not a valid member of DataModel"

0

That's the same thing, you're directing the script to workspace, and not the model, again.

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.

1 comment

0

Got error... 16:58:09.640 - Center is not a valid member of Folder

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