Script.parent.touched doesnt work

I’m trying to make the exit code for my game, but the script.parent.touched doesn’t work. It’s supposed to detect when a plank is touching it but even if it gets touched by anything else it still doesn’t say it was touched.

script.Parent.Touched:Connect(function(hit)
	print(hit.Name)
	if hit.Name == "Plank" then
		script.Parent.Parent.Broken.Transparency = 1
		script.Parent.Parent.Normal.Transparency = 0
		hit:Destroy()
		script.Parent:Destroy()
	end
end)
2 Likes

So nothing is printing? Could the part that you touch has CanTouch = false?

2 Likes

CanTouch is true. extrawordssoicansendit

2 Likes

Could then the script be a LocalScript? Nothing seems wrong with the script itself, it might be the properties of your part/script or how it’s placed.

3 Likes

I would recommend doing this.

Put it in a folder and enter this script

script.Parent.Touched:Connect(function(hit)
	print(hit.Name)
	if hit.Parent.Name == "Folder" then
		script.Parent.Parent.Broken.Transparency = 1
		script.Parent.Parent.Normal.Transparency = 0
		hit:Destroy()
		script.Parent:Destroy()
	end
end)

It lags out if you do hit.Name

1 Like

It’s a normal script, and none of the property’s seem off.

1 Like

Where is the script located? It has something to do with its location.

1 Like

The hitbox part. extrawordssoicansendthis

1 Like

What is the hitbox part? We need more context.


This is the hitbox part.

make sure all colliding parts are actually touching and the both have CanTouch set to true. is there is a chance that they may appear to be touching but not?

I’m sure they are touching, and they both have CanTouch set to true.

just tested the script it does work fine so idk.


sorry its laggy.

Ok so it somehow fixed itself now :sweat_smile:

thats good. maybe just studio having a day. :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.