I thought this was a good script but for some reason they dont let you go through
h1 = game.Workspace.Kingdom.Hidden1 h2 = game.Workspace.Kingdom.Hidden2 script.Parent.Touched:connect(function() h1.CanCollide = false h2.CanCollide = false end)
It would be best to provide more information as to your intention when asking a question. Assuming that you want the event to fire when a player touches the block, then you would have to make sure that it has a humanoid, as the Touched
event fires whenever anything touches it. Also these have to be parts. If you're wanting to turn all the parts inside to a CanCollide then use a for loop.
local h1 = game.Workspace:WaitForChild('Kingdom'):WaitForChild('Hidden1') --I would recommend adding WaitForChild to these as it will wait for the Hidden1to load local h2 = game.Workspace:WaitForChild('Kingdom'):WaitForChild('Hidden2') script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') h1.CanCollide = false h2.CanCollide = false end end)
Add a regular script into a Kingdom then put this
Part.Touched:connect(function(HIT) local H = HIT.Parent:FindFirstChild("Humanoid") if H then script.Parent.CanCollide = false --false or true can work-- end end)
Or if you want it to open for few second do
Part.Touched:connect(function(HIT) local H = HIT.Parent:FindFirstChild("Humanoid") if H then script.Parent.CanCollide = false wait(5) script.Parent.CanCollide = true end end)