Im trying to make a bridge that activates when a cube touches a pad
I keep having a problem where i made a variable “bridge” but when i try to set a part’s transparency that’s a child of “bridge” it gives me an error saying that “PlankShadow is not a valid member of Script “Workspace.Rooms.Room4.Bridge””.
code:
local cube = script.Parent.BridgeCube
script.Parent.BridgePad2.CubeSpot.Touched:Connect(function(hit)
if hit.Name == "BridgeCube" then
script.Parent.BridgeSpawn.Playing = true
cube.Color = Color3.fromRGB(71, 71, 71)
cube.CanCollide = false
for i = 1,10,1 do
cube.Transparency = cube.Transparency + 0.1
wait(0.05)
end
cube:Destroy()
wait(0.5)
local bridge = script.Parent.Bridge
bridge.PlankShadow.Transparency = 0.5
local Y = 16.609
for i = 1,25,1 do
bridge.PlankShadow.Position = Vector3.new(-216.552, Y, 30.625)
Y = Y - 0.25
bridge.PlankShadow.Position = Vector3.new(-216.552, 11.609, 30.625)
wait(0.02)
end
bridge.PlankShadow:Destroy()
bridge.plank.CanCollide = true
bridge.plank.Transparency = 0
script:Destroy()
end
end)
Error message:

Explorer:

I’ve tried using WaitForChild and FindFirstChild, i tried rewriting it but nothing i tried fixed it
Im not sure why it worked before but doesn’t work this time.