I want to create a part that disables walk-thru after someone has touched another part

  1. What do you want to achieve? A part that disables collision 2 seconds after you touch another part, and then a cooldown before you can walk-thru it again and repeat the cycle

  2. What is the issue? I’ve searched around and didn’t exactly find what i was looking for

  3. What solutions have you tried so far? Mentioned above, i’ve looked for a forum-post that has the same question, to no avail.

4 Likes

idk wdym by walkthrough but if it’s about freezing the player for 2 seconds then uses this script

local part = script.Parent

local debounce = false

part.Touched:Connect(function(hit)
	if not debounce then
		debounce = true
		
		if hit.Parent:FindFirstChild("Humanoid") then
			hit.Parent.Humanoid.WalkSpeed = 0
			hit.Parent.Humanoid.JumpPower = 0
			hit.Parent.AutoRotate = false
			task.wait(2)
			hit.Parent.Humanoid.WalkSpeed = 16.2
			hit.Parent.Humanoid.JumpPower = 50
			hit.Parent.AutoRotate = true
		end
		task.wait()
		debounce = false
	end
end)

4 Likes

you know that you can change the way how you interact with a part, you can either walk thru it or not, basically collision

3 Likes

This can be achieved through collision groups. If you want a part which, when touched, ceases another parts collisions entirely, you can use getchildren which you will need all of them parented to. Or collectionservice, which doesn’t require this. I don’t advise using getdescendants.

3 Likes

could you give an example script maybe? I’m not that good at scripting but learning

3 Likes

script.Parent.Touched:Once(function(hit)
for _,v in workspace.Folder:GetChildren() do
v.CanCollide = false
v.CanQuery = false
v.CanTouch = false
end
end)

3 Likes

If you want it to run only once, keep Once, or replace with Connect. Though you should add a debounce if you are going to do so. Add a task.wait after altering the properties to reset them back.

2 Likes

it’s going to be repeated every time it’s touched

3 Likes

That’s why I added Once instead of Connect

1 Like

the thing is, there should be a cooldown before there’s no collision again, like. 1 minute

2 Likes

local Debounce

script.Parent.Touched:Connect(function(hit)
if not Debounce then Debounce = true
print(“init”)
for _,v in workspace.Folder:GetChildren() do
v.CanCollide = false
v.CanQuery = false
v.CanTouch = false
end
task.wait(10)
print(“over”)
for _,v in workspace.Folder:GetChildren() do
v.CanCollide = true
v.CanQuery = true
Debounce = nil
end
end
end)

1 Like

Probably works. I just stacked a bunch of parts and they just fall out of map lol

1 Like

the part still has no collision, even when i touched it

1 Like

local Debounce

script.Parent.Touched:Connect(function(hit)
if not Debounce then Debounce = true
print(“init”)
for _,v in workspace.Folder:GetChildren() do
v.BrickColor = BrickColor.new(“Cocoa”)
v.CanCollide = false
v.CanQuery = false
v.CanTouch = false
end
task.wait(10)
print(“over”)
for _,v in workspace.Folder:GetChildren() do
v.BrickColor = BrickColor.new(“Forest green”)
v.CanCollide = true
v.CanQuery = true
Debounce = nil
end
end
end)

1 Like

It goes back to collideable after 10s

1 Like

retouch to go back to uncollideable

1 Like

it sadly doesn’t work, i don’t know what i did wrong

2 Likes

Mind showing a screenshot of the folder?

2 Likes

image
The part that should get collision after touching and a few seconds is called “Part”, and is in no folder

Ok. GetChildren won’t work in that case

1 Like