Making throwable item "throwable"

I have a script that “throws” a part, its not the best, i want to make it as accurate as possible, how could i do this?

this is a snippet of the script and the code i want adjusted.

RemoteEvent.OnServerEvent:Connect(function (plr, SetPosition, LookVector)
	local NewSpell = spell:Clone()
	NewSpell.Fire.CanCollide = true
	NewSpell["Sphere.001"].CanCollide =true
	NewSpell["Sphere.001"].HandleWeld:Destroy()
	NewSpell.Parent = game.Workspace
	NewSpell.Fire:SetNetworkOwner(plr)
	NewSpell["Sphere.001"]:SetNetworkOwner(plr)
	NewSpell:PivotTo(CFrame.new(SetPosition))
	local LV = Instance.new("LinearVelocity")
	LV.Parent = NewSpell.Fire
	LV.Attachment0 = NewSpell.Fire.Attachment
	LV.MaxForce = 500
	LV.VelocityConstraintMode = Enum.VelocityConstraintMode.Line
	LV.LineVelocity = 500
	LV.LineDirection = LookVector + Vector3.new(0, 0.5,0)
	task.wait(0.2)
	LV:Destroy()
end)

When I make grenades/throwables in my games, I set them up like this.

  • Detect tool activation
  • Create part on tool position
  • Delete tool
  • Launch part
  • Wait
  • Explode part

If you want to make a throwable, use this script. (I’m not using an IDE, so there might be small mistake.)

local tool = script.Parent

tool.Activated:Connect(function()
    local mouse = game.Players.LocalPlayer:GetMouse()

    local projectile = instance.new("Part")
    projectile.Shape = Enum.PartType.Ball
    projectile.Size = Vector3.new(1, 1, 1)
    projectile.Parent = game.Workspace
    projectile.Position = tool.Handle.Position
    
    projectile.Anchored = false
    projectile.CanCollide = true

    local speed = 1000
    projectile.CFrame = CFrame.new(projectile.Position, mouse.Hit.Position)
    projectile.Velocity = projectile.CFrame.LookVector*speed

    tool:Destroy()
end)
1 Like

Got it, ill try this out later and see if it works!