I’m attempting to creating a player fired missile system, which i have for the most part. But once the rocket reaches it’s Target (using ReachedTarget) the explosion is not at the location of where the rocket is, instead its in the middle of the baseplate.
Here’s a video of it happening:
https://gyazo.com/9897d17e46c212ecf7408a5adb1d89e9
Here’s my code
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local part = game.Workspace.Part -- Just assuming there's something here based on your script.
local startPoint = part.CFrame.p -- This will be the firing point basically
local speed = 100
mouse.Button1Down:connect(function()
local lookPoint = mouse.Hit.p
local heightPoint = game.Workspace.Height.CFrame.p
local Location = Instance.new("Part",game.Workspace);
Location.CFrame = mouse.Hit;
local projectile = game:GetService("ReplicatedStorage"):WaitForChild("Missle"):Clone()
projectile.Parent = workspace
projectile.CFrame = CFrame.new(startPoint)
wait(2)
projectile.CFrame = CFrame.new(heightPoint) -- Projectile starts at "startPoint", while looking at "lookPoint"
mouse.TargetFilter = projectile -- The mouse will ignore the projectile so it doesn't end up above the mouse position
wait (0.5)
local BV = Instance.new("RocketPropulsion") -- Creating body velocity
BV.Target = Location
BV.Parent = projectile
BV.ThrustP = 100
BV.MaxSpeed = 200
BV.CartoonFactor = 100
BV:Fire()
BV.TargetRadius = 5
BV.ReachedTarget:Connect(function(e)
local x = Instance.new("Explosion", projectile)
x.BlastRadius = 15
end)
end)