Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

parts not detecting being touched, why ?

i have made a cannon that fires a ball, however i want the ball to anchor when it hits the basepart, however it only fires when it touches me

the code as follows is placed in a script in the part

script.Parent.Touched:Connect(function(hit)
	if hit.Name == "Baseplate" then
		script.Parent.Anchored = true
	end
end)

2 comments

0

Is this code in a local script?

0

Are you able to give us the screenshot of the workspace?

3 answers

Not sure what you really mean here. "it only fires when it touches me" if you mean for it to fire when you do something else like clicking it your script should be like:

1, put a click detector in the part

script.Parent.ClickDetector.MouseClick:Connect(function(hit)
    if hit.Name == "Baseplate" then
        script.Parent.Anchored = true
    end
end)

1 comment

0

He's trying to make a cannon. When the ball of the cannon HIT the ground (Baseplate), it anchors itself. But in this case, it only fires if the ball hit the player's character.

Touched event doesn't fire when two anchored parts touch. That means you have to use hinge to keep the part in place and the touch event to work.

1 comment

0

The cannon ball isn't anchored when it hits it though, it only IS anchored when it touches it.

This discussion is preserved as it was. New answers, comments, and votes are closed.