[SOLVED] script.Parent.Touched doesn't seem to work as expected

Hey! I’m a newbie when it comes to scripting, so I made a script as a child of a part,
and I made it so that if it’s touched ,
it clones a mesh (in replicatedstorage ) to workspace but it seems to not work,
i’ve made the script check if a humanoid touched it,
but doesnt work. Please help!

script:



script.Parent.Touched:Connect(function(hit)
	if hit.Parent == "Humanoid" then
		local replicated = game:GetService("ReplicatedStorage")
		
		local clone = replicated.TrapWall:Clone()
		
		clone.Parent = workspace


	end

end)

here are screenshots:
Screenshot 2022-09-25 203658

and here is the mesh in replicatedstorage.

Screenshot 2022-09-25 203810

2 Likes

try

if hit.Parent:FindFirstchild("Humanoid") then

Instead of

if hit.Parent == "Humanoid" then

Alright will try!

Oh my gosh, thank you so much! It works, I appreciate it man. I never knew it would be such a simple fix lol! ty. :smile:

Don’t worry, its fine!

You are simply checking if “hit”(the part that touched it)'s parent has a humanoid.

1 Like

If you need any more help you can DM me!

2 Likes