I’ve made a fireball with some help. But, instead of it going to the look vector how do I make go where the mouse position is? I know I can use Mouse.Hit.p. But, I don’t know how those things work so any examples would be great!
Im new to fourms but maybe its like this IDK how to make it scrollable text thing
local Fireball = game.ServerStorage:WaitForChild(“Fireball”)
local Clone = Fireball:Clone()
local Character = Player.Character
Clone.Parent = workspace
Clone.Position = Character.HumanoidRootPart.Position + Character.HumanoidRootPart.CFrame.LookVector * 1
local rp = game:GetService("ReplicatedStorage")
local Fireball= rp:WaitForChild("Fireball")
Fireball.onServerEvent:Connect(function(Player,mousehit)
-- then just insert previous code and it will work I think
end)
After the input has began you should connect to the server using a remote event passing the mouse position as one of the arguments
On the server script clone the fireball into the workspace and add a BodyForce on to it so that it stays up or else because of gravity the fireball may go in that direction but it will fall
to define the bodyforce do this:
local BodyF= Instance.new(“BodyForce”)
BodyF.Force = Vector3.new(0,clonedpart:GetMass * workspace.Gravity,0)
BodyF.Parent = clonedpart
So here we make the part stay up in the air and now you want it to travel the direction of where your mouse is
to define this simply do this:
local direction = (mousepos - originpos).Unit*100 --Origin pos is where ur part will spawn
now the direction is defined and make sure these are on server script after the input has began.
Now to make the part travel in that direction make the velocity of the part equal to the direction
clonedpart.Velocity = direction
Now the part will travel in that direction.