Hello, I am making a grenade, everything works properly, only a problem, I want the Z velocity to be set as mouse’s position’s Z-axis. Doesn’t work properly, here’s the code:
local Player = game.Players.LocalPlayer;
local Mouse = Player:GetMouse();
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local Ball = ReplicatedStorage:WaitForChild("Ball")
local Character = Player.Character;
local debounce = false
local RightHand = Character:WaitForChild("RightHand")
Mouse.Button1Down:Connect(function()
local newBall = Ball:Clone();
newBall.Parent = game.Workspace;
newBall.CFrame = RightHand.CFrame * CFrame.new(workspace.Camera.CFrame.LookVector) * CFrame.new(0, 0, -5)
local gravity = 100
local objectedSpace = workspace.Camera.CFrame:ToObjectSpace(Mouse.Hit)
newBall.Velocity = newBall.CFrame * Vector3.new(0, gravity, -objectedSpace.X)
newBall.Touched:Connect(function()
if debounce == false then
debounce = true
local exp = Instance.new("Explosion", workspace)
exp.Position = newBall.Position
newBall:Destroy()
wait(1)
debounce = false
end
end)
end)
