Why every time i change speed it affects where the object goes not correctly shooting where mouse is clicking?

  1. i’m trying to make a fireball basically where when clicked say a wall the ball will move where the mouse is aiming at basically.

  2. everytime i try changing the speed of the ball it makes the ball move upwards while also affecting the speed also the mouse aiming part doesn’t work correctly?

  3. i tried looking it up on youtube and even when done right it still had same issue asked gpt for help cause why not, but still pointless, gpt is really bad at lua honestly and i tried changing the vector tried changing the objectClone.CFrame = player.Character.HumanoidRootPart.CFrame + Vector3.new(-2, -2, -2) to instead of vector3 tried using the mouse but still nothing i fr tried using mouse in multiple ways and i can’t figure it out.

local event = script.Parent:WaitForChild("Event")
local object = game:GetService("ReplicatedStorage").Object:FindFirstChild("ball")

event.OnServerEvent:Connect(function(player, mouse)
	local character = script.Parent.Parent

	local objectClone = object:Clone()

	objectClone.Parent = workspace
	objectClone.CFrame = player.Character.HumanoidRootPart.CFrame + Vector3.new(-2, -2, -2)

	local bodyVelocity = Instance.new("BodyVelocity")
	bodyVelocity.Velocity = Vector3.new(20,20,20) -- Adjust the speed as needed
	bodyVelocity.MaxForce = Vector3.new(10000, 10000, 10000) -- Adjust the force as needed
	bodyVelocity.Parent = objectClone

	
	task.wait(6)  
	objectClone:Destroy()
end)

you’re supposed to pass mouse.Hit as the argument in localscript btw

local event = script.Parent:WaitForChild("Event")
local object = game:GetService("ReplicatedStorage").Object:FindFirstChild("ball")
local speed = 7.5 
event.OnServerEvent:Connect(function(player, mouse)
	local character = script.Parent.Parent

	local objectClone = object:Clone()

	objectClone.Parent = workspace
	objectClone.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame
new(0,0,-3)

	local bodyVelocity = Instance.new("BodyVelocity")
	bodyVelocity.Velocity = CFrame.new(objectClone.Position, mouse.p).LookVector * speed
	bodyVelocity.MaxForce = Vector3.new(10000, 10000, 10000) -- Adjust the force as needed
	bodyVelocity.Parent = objectClone

	
	task.wait(6)  
	objectClone:Destroy()
end)
1 Like

i tried before using mouse.Hit but it gave me an error that didn’t even make sense. i’ll re try and tell you what it said but making some other project rn.