Basically, if you touch a keycard reader (one of its children) the brickcolor of that part (that was touched) is supposed to turn green and flip a value of a bool value inside another model but it’s printing a error that the bool value is not a valid member of the model. Also tried using waitforchild but doesn’t work.
The error:
Where the bool value is stored:
Script for the touch part.
local Open = script.Parent.Parent.Parent:FindFirstChild("Door").OpenDoor -- This is where it errors
script.Parent.Touched:Connect(function(hit)
if hit.Parent:IsA("Tool") and hit.Parent.Name == "Royal Access Card" then
Open.Value = true
script.Parent.BrickColor = BrickColor.new("Bright green")
wait(1)
Open.Value = false
script.Parent.BrickColor = BrickColor.new("Institutional white")
else wait(.5)
Open.Value = false
script.Parent.BrickColor = BrickColor.new("Really red")
wait(1)
script.Parent.BrickColor = BrickColor.new("Institutional white")
end
end)
local Open = script.Parent.Parent.Parent:FindFirstChild("Door").OpenDoor
Really curious how it turned into script.Parent.Parent.Parent, even if the bool value is one hierarchy away. Replace it with: script.Parent:FindFirstChild("OpenDoor")or script.Parent.OpenDoor
local moving
local originalLeft = script.Parent.Left.PrimaryPart.CFrame
local originalRight = script.Parent.Right.PrimaryPart.CFrame
local function move()
for i=1,30 do
script.Parent.Left:SetPrimaryPartCFrame(originalLeft * CFrame.new(-9.2*(i/30),0,0))
script.Parent.Right:SetPrimaryPartCFrame(originalRight * CFrame.new(9.6*(i/30),0,0))
wait()
end
wait(2.5)
for i=29,0,-1 do
script.Parent.Left:SetPrimaryPartCFrame(originalLeft * CFrame.new(-9.2*(i/30),0,0))
script.Parent.Right:SetPrimaryPartCFrame(originalRight * CFrame.new(9.6*(i/30),0,0))
wait()
end
wait(1)
end
if script.Parent.OpenDoor.Value == true then
print("shshdhdh")
moving = true
move()
moving = false
end
This line… local Open = script.Parent.Parent.Parent:FindFirstChild("Door").OpenDoor
…would look like this: local Open = script:FindFirstAncestor("Map"):FindFirstChild("Door").OpenDoor
More information here.
For the opening part, you are not connecting it to any event, rendering it not functional. Try not adding new replies, just edit your previous reply. Instead, I would connect to the Changed event on the value object to check if it turned true or not.