Hello, I've been working on this script for a few days now, but it's not working. This script is meant to print a message if a MeshPart is hitting the Part.
Here's a picture of when this is meant to happen: Here
script.Parent.Touched:Connect(function(hit) local h = hit if (h ~= nil) then if h:IsA("MeshPart") then print(h.Name.."hit me!") game.ReplicatedStorage:WaitForChild("vals"):WaitForChild("Winner").Value = h.Name script.Parent:Destroy() end end end)
Any help would be appreciated. Thanks in advance!
script.Parent.Touched:Connect(function(hit) if hit.Parent:IsA("MeshPart") then print(hit.Parent.Name.."hit me!") --If not working try use hit.Parent only game.ReplicatedStorage:WaitForChild("vals"):WaitForChild("Winner").Value = hit.Parent.Name --Here too script.Parent:Destroy() end end)
I hope this will work
Sooo, I solved this myself, because apparently if you turn Anchored
on, it won't detect the part, even with CanCollide
on!