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

How to check if a part goes through another part? (Like space invaders, when a bullet hits an enemy)

Asked by 8 years ago
Edited 8 years ago

I have a space-invader like game, when a part goes though another (both CFramed) The enemy gets killed (:Destroy())

-- Basic Script I am using
script.Parent.Touched:connect(function()
    script.Parent:Destory()
end)

I was informed somewhere that :Touched event doesn't work with parts being CFramed, in my case both parts are

0
I would test before making assumptions. It used to be the case that CFrames didn't fire Touched events, but I'm not sure now. adark 5487 — 8y
0
Yeah it still doesn't, I tried before Script0rr 65 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

I dont really know how to do that, but I would recommend simply using a part to do the .Touched event. To do that you can use a script like this:

local Part = Instance.new("Part", workspace)
    Part.Size = Vector3.new(0.1,0.1,0.1)
    Part.Shape = ("Ball")
    Part.Position = Vector3.new(-3.5,0.5,4.5)
    Part.CFrame = tool.Handle.CFrame
    Part.CFrame = CFrame.new(Part.Position,mouse.Hit.p)
    local v = Instance.new("BodyVelocity", Part)
    v.velocity = Part.CFrame.lookVector *90
    v.maxForce = Vector3.new(math.huge, math.huge, math.huge)

Of course, I am also new to scripting so dont expect much from me. I hope this helped.

0
How is your script helping him understand the touched event? Am I missing something here iamnoamesa 674 — 8y
Ad

Answer this question