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)
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)
I know why it is not working it is in a local script... is there anyway to fire it inside of a local script
it should work in a local script
It finally worked thanks!
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Are the parts single parts or models? Also i'm not sure if this is some sort of button, but this will fire when the part that the script is inside of it touched. It's also recommended to change those variables to local variables.