Ball Tool Flings Me Instead

I’m trying to throw a basketball tool, but it flings me instead:

local UserInputService = game:GetService("UserInputService")
local applyImpulseOnBallRemote = game:GetService("ReplicatedStorage")["Apply Impulse on ball"]

local camera = workspace.CurrentCamera
local tool = script.Parent
local toolHandle = tool:FindFirstChild("Handle")

local params = RaycastParams.new()
params.FilterDescendantsInstances = {} -- anything you want, for example the player's character, the ray filters through these
params.FilterType = Enum.RaycastFilterType.Exclude -- choose exclude or include

local function rayResult(x, y)
	local unitRay = camera:ViewportPointToRay(x, y) -- :ViewportPointToRay() is another choice
	return workspace:Raycast(unitRay.Origin, unitRay.Direction * 500, params) -- 500 is how far to raycast
end
tool.Activated:Connect(function()

	local mouse = UserInputService:GetMouseLocation()
	local result = rayResult(mouse.X, mouse.Y)
	if result then
		print(result.Instance, result.Position)
		tool.Parent = workspace
		
		toolHandle.AssemblyLinearVelocity = result.Position * toolHandle.AssemblyMass * 120
		applyImpulseOnBallRemote:FireServer(tool, result) -- On the server
	end
end)


2 Likes

does this work?
if you don’t do the set velocity, will the tool drop on ground?

if it works, how about if you add task.wait() after parent it to workspace

Maybe it’s about he setting the parent on the client side (I assume this is a localscript because the :FireServer

I don’t know if the client has the power to change the tool in the server as it does with animations

in that case maybe calling Humanoid:UnequipTools() may work