there are. more than a few things wrong with this
for one, mouse.X and mouse.Y describe the mouse's position on the player's screen, not in the world—for that you'd use mouse.Hit
second, you should spawn the ball on the server, or else other players won't be able to see it
third, you shouldn't spawn the tool inside the player's head, but a bit in front of it, so that the physics engine doesn't go all crazy and stupid and dumb
fourth, you should use HumanoidRootPart for anything related to character positioning. it's more reliable and less likely to be changed by roblox
fifth, velocity being at 1000 is just. way too high
sixth, the velocity should be constant—if you throw from really far away, it shouldn't go faster than if you just threw it right next to yourself
seventh, the velocity should be calculated using mouse position relative to the character's position, or else it'll go in the wrong direction
and eighth, you should clone the tool every time it's thrown, or else if the player throws it multiple times the old one will just disappear (or it'll error, if it fell into the void)
local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character
local mouse = player:GetMouse()
tool.Activated:Connect(function()
tool.Throw:FireServer(mouse.Hit.p)
end)
local tool = script.Parent
local character = tool.Parent
tool.Throw.OnServerEvent:Connect(function(player, mousePos)
local startPos = (character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -1)).p
local velocity = (mousePos - startPos).Unit * 50
local ball = tool.Handle:Clone()
ball.Position = startPos
ball.Velocity = velocity
ball.Parent = workspace
end)
you need to put a RemoteEvent in the tool, since the client has to send the mouse position to the server
it doesn't have to be named Throw, but you should name it something descriptive
2 comments
can you describe your problem please?
you could use lerp