Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Do i Make this FireBall aim at the mouse?

Asked by 5 years ago

https://gyazo.com/ad7b0ec9c1cc69ce7b40119e41d8f684

here is the script that fires a Remote Event when Q is pressed

wait(2)
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local mouse = player:GetMouse()
local CoolD = 0
mouse.KeyDown:Connect(function(key)
    local Key = key:lower()
    if key == "q" and CoolD == 0 then
        CoolD = 1
        print("Fired")
        script.FireBallShoot:FireServer()
        wait(1)
        CoolD = 0
    end 


end)

The script Above is in a local Script

here is the script that makes the body velocity and shoots where the humanoidRootPart is facing

script.Parent.FireBallShoot.OnServerEvent:Connect(function(Player)
    local ball  = game.ReplicatedStorage.FireBall:Clone()
    ball.CFrame = Player.Character.HumanoidRootPart.CFrame

    local BodyV = Instance.new("BodyVelocity")
    BodyV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    BodyV.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector * 50
    BodyV.Parent = ball
    ball.Parent = workspace

end)

The script above is located in a server script

I would like it to shoot where the mouse is pointing. PS. the ball is located in Replicated Storage

thx in advance

0
To get a vector from point A to point B, do (B - A). This will include distance - to re-scale it, do (B - A).unit * newDistance. fredfishy 833 — 5y
0
can you tell me what to change NathanGaming2005 2 — 5y

Answer this question