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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
moo1210 587 Moderation Voter
4 years ago

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

0
Thanks! That's work. But now there is error " 17:01:59.217 - Touched is not a valid member of DataModel" Maksilot 9 — 4y
0
That's the same thing, you're directing the script to workspace, and not the model, again. killerbrenden 1537 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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.

0
Got error... `` 16:58:09.640 - Center is not a valid member of Folder`` Maksilot 9 — 4y

Answer this question