Here we go: I wanted to make my own rocket launcher tool from scratch because I want to be able to easily configure it is settings and understand what is going on in it’s script.
So I did everything to make it work: made it so upon tool activation a new part is instanced, and all the needed forces are applied to it. The problem is, that upon missile’s collision on any object, it seems to be weirdly affected by physics in a way that it starts spinning uncontrollably for a brief second.
I tried applying body gyro, I even tried using RunService to constantly keep the missile’s orientation as intended, yet it still would not work.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local tool = script.Parent
local handle = script.Parent.Handle
local fireEvent = script.Parent.Fire
local config = script.Parent.Config
local RunService = game:GetService("RunService") -- Me trying to use it for keeping the orientation of the rocket right, although i deleted that section of the script
fireEvent.OnServerEvent:Connect(function(player, mousehit)
local missile = Instance.new("Part")
missile.BrickColor = BrickColor.new("Black")
missile.Parent = workspace
missile.CFrame = CFrame.new(handle.Position, mousehit)
missile.Size = Vector3.new(1,1,3)
local constantOrientation = missile.Orientation
local fire = Instance.new("Fire", missile)
fire.Size = 3
fire.Heat = 25
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Parent = missile
bodyVelocity.Velocity = missile.CFrame.LookVector * config.Speed.Value
bodyVelocity.MaxForce = Vector3.new("inf", "inf", "inf")
local swoosh = tool.Swoosh:Clone()
swoosh.Parent = missile
swoosh:Play()
local debounce = false
missile.Touched:Connect(function(hit)
if hit ~= handle and not tool.Parent:FindFirstChild(hit.Name) and debounce == false and hit:IsA("BasePart") and hit.Transparency <= 0.4 then
bodyVelocity:Destroy()
fire:Destroy()
missile.Transparency = 1
missile.CanCollide = false
if swoosh.IsPlaying == true then
swoosh:Destroy()
end
debounce = true
local explosion = Instance.new("Explosion", workspace)
explosion.Position = missile.Position
explosion.DestroyJointRadiusPercent = 0
explosion.BlastPressure = 0
local boom = tool.Boom:Clone()
boom.Parent = missile
explosion.BlastRadius = config.BlastRadius.Value
local damageRadius = Instance.new("Part", workspace)
damageRadius.Transparency = 1
damageRadius.CanCollide = false
damageRadius.Shape = Enum.PartType.Ball
damageRadius.Position = missile.Position
damageRadius.Anchored = true
local blastRadius = config.BlastRadius.Value
damageRadius.Size = Vector3.new(blastRadius,blastRadius,blastRadius)
damageRadius.Touched:Connect(function(touch)
if touch.Parent:FindFirstChild("Humanoid") then
touch.Parent.Humanoid:TakeDamage(config.Damage.Value)
if touch.Parent.Humanoid.Health == 0 then
if player.Character.Humanoid.Health ~= 100 then
player.Character.Humanoid.Health = player.Character.Humanoid.Health + 20
if player.Character.Humanoid.Health > 100 then
player.Character.Humanoid.Health = 100
end
end
end
damageRadius:Destroy()
end
end)
boom:Play()
wait(boom.TimeLength)
missile:Destroy()
debounce = false
end
end)
end)