-
What do you want to achieve? Keep it simple and clear!
I want to make my fireball maintain a consistent speed when it moves, and I want to see if there’s a better way of moving projectiles. -
What is the issue? Include screenshots / videos if possible!
My fireball script works so far, but not exactly how I expected it to.
When I fire the projectile, the speed varies on where my mouse is, and that’s not really what I was aiming for. I wanted the speed to be consistent, and just make the projectile go in the direction of where my mouse is but have a set velocity. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’m new to the DevHub and so I might’ve navigated it incorrectly, but I didn’t find any solutions on the DevHub. I tried using CFrame and bodymovers, but I still had the same result.
Here’s my localscript first:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Mouse = Player:GetMouse()
local MagicEvent = ReplicatedStorage:WaitForChild("MagicFired")
local InputService = game:GetService("UserInputService")
local Debounce = false
InputService.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Q then
MagicEvent:FireServer(Mouse.Hit, Mouse.Hit.Position)
end
end)
Here’s my serverscript:
local RepStor = game:GetService("ReplicatedStorage")
local MagicEvent = RepStor:WaitForChild("MagicFired")
local Tweenservice = game:GetService("TweenService")
local EaseStyle = Enum.EasingStyle.Linear
local EaseDirection = Enum.EasingDirection.InOut
MagicEvent.OnServerEvent:Connect(function(Player, MouseHit, MouseHitP)
local Fireball = RepStor:WaitForChild("Fireball")
local Character = Player.Character
local HRT = Character:WaitForChild("HumanoidRootPart")
local FireballClone = Fireball:Clone()
FireballClone.Parent = workspace
FireballClone.CFrame = HRT.CFrame
local TweenInformation = TweenInfo.new(2, EaseStyle, EaseDirection)
local TweenGoals = {Position = MouseHitP}
local TweenCreation = Tweenservice:Create(FireballClone, TweenInformation, TweenGoals)
TweenCreation:Play()
end)
Basically, I just want to know if there’s a way to make my fireball move at a certain speed and not depend on my mouse’s position.