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

How to make a part be thrown away if it touches another when clicking?

Asked by 3 years ago
Edited 3 years ago

Hello! I would like to make that when clicking on a specific part (part 1) only if it is touched by part2 at the moment of the click, the part2 is thrown away, how can I do something like that?

I would like it to be thrown away like when you throw a ball, this is for a baseball game and I want to do that when the bat tool touches the box and if at that moment the ball also touches the box then the ball is thrown far in the direction positive x

local part = script.Parent
local click = part.ClickDetector

local function throwAway ()
    -- code here
end

click.MouseClick:Connect(throwAway)
0
Do you mean that you completely want to destroy the part like using the Destroy() function as like you click on it and it gets destroyed? iamajunky 20 — 3y
0
I would like it to be thrown away like when you throw a ball, this is for a baseball game and I want to do that when the bat tool touches the box and if at that moment the ball also touches the box then the ball is thrown far in the direction positive x MatiasHarders 0 — 3y
0
Sounds like you need to create a hitbox using a part then you change transparency, anchor it, and put can collide off. Then make a script when the handle and the ball touches the hit box the then it changes the body velocity of the ball and direction to go whatever way you want it. I will try to reattempt this in code and get back to you with a code example. iamajunky 20 — 3y
0
yes! exactly that i need! :D thanks you a lot MatiasHarders 0 — 3y

Answer this question