I’m trying to make a rocket launcher, I got everything working except for the ammo. Yeah the ammo moves and goes to the mouse.hit.p and stuff but the one problem is, the ammo dosent explode when it touches parts, only players
Tried using .Touched event but only detects players, I also want it to fire when it touches parts
I’m not asking for full codes but I want to know how to make it like should I use magnitude?
Code:
local part1 = workspace.Part1
local part2 = workspace.Part2
local pos = CFrame.new(part1.Position, part2.Position)
part1.CFrame = pos
local tweeninfo = TweenInfo.new(8)
local animation = game:GetService("TweenService"):Create(script.Parent,tweeninfo,{Position=script.Parent.pos.Value})
animation:Play()
script.Parent.Touched:Connect(function(part)
local boom = Instance.new("Explosion")
boom.Position = script.Parent.Position
boom.Visible = true
boom.Parent = game.Workspace
script.Parent:Destroy()
end)
.Touched detects parts as well, make sure the function connected to the .Touched event isn’t excluding parts which don’t belong to the characters of players.
As far as I’m aware, it doesn’t. Maybe it is an issue of not detecting touch because the part doesn’t touch other parts due to wanky hitboxes? Probably not the issue though. You could try making a larger hitbox that doesn’t collide (assuming the bullet part has CanCollide on).
The issue is probably script-related. Maybe you accidentally excluded the touching of other parts (by only running the script if the person is has a humanoid). Try putting a print statement at the very beginning of the function (right after the function declaration) and print the part touched. If it prints normal parts as well, then it is definitely a script-related issue. Also, it is quite difficult for us to help you without the script, so I suggest you post that too. You don’t need the whole script, just the touch function.
I think the problem is that when using a touched event one part has to be un-anchored. Every part in a character is un-anchored so, it’s either your rocket launcher is anchored or the part you want to hit is anchored.