How would I make it so the projectile went forward even though it follows my mouse.
Here’s the script.
local UIS = game:GetService(“UserInputService”)
local RunService = game:GetService(“RunService”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local RE = ReplicatedStorage.Missile
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local MaxDistanceTraveled = 300
local mouse = game.Players.LocalPlayer:GetMouse()
local MissleVelocity = 1
UIS.InputEnded:Connect(function(input,typing)
if input.KeyCode == Enum.KeyCode.F and not typing then
local autoTrack = Instance.new("RocketPropulsion")
autoTrack.ThrustP = Vector3.new(1,1,1)*150000
local MagicMissle = ReplicatedStorage.MagicMissle:Clone()--The magic thingy we are firing forward
local StartPos = char:WaitForChild("RightHand").Position
MagicMissle.Position = StartPos
autoTrack.Parent = MagicMissle
MagicMissle.Parent = workspace --Parenting it to workspace so we can see it
local OnFrame --this is the variable that will hold our .Heartbeat connection
OnFrame = RunService.RenderStepped:Connect(function(DeltaTime)--runs every frame
MagicMissle.CFrame *= CFrame.new(0,0, -MissleVelocity * DeltaTime * 60)
autoTrack.TargetOffset = mouse.Hit.p
autoTrack:Fire()
if (MagicMissle.Position - StartPos).Magnitude > MaxDistanceTraveled then
--the missle went too far!
MagicMissle:Destroy()
else
game.Debris:AddItem(MagicMissle, 10)
end
end)
end
end)