Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

parts not detecting being touched, why ?

Asked by 2 years ago

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)
0
Is this code in a local script? ghostbettert 30 — 2y
0
Are you able to give us the screenshot of the workspace? NotThatFamouss 605 — 2y

3 answers

Log in to vote
0
Answered by 2 years ago

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)
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. NotThatFamouss 605 — 2y
Ad
Log in to vote
0
Answered by
SuperPuiu 497 Moderation Voter
2 years ago

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.

0
The cannon ball isn't anchored when it hits it though, it only IS anchored when it touches it. DocGooseYT 110 — 2y
Log in to vote
0
Answered by 2 years ago

fixed

Answer this question