Making this post because I didn’t see valid answers to similar ones on the forum.
I am trying to make a tool to where if the player clicks it, it sends the dart flying to where he clicked it and it anchors to the wall.
Problem(s):
The throw of the projectile isnt smooth (im using bodyvelocity)
Sometimes it sticks to the air
Sometimes it sticks way past the brickpart
Sometimes it just randomly doesnt stick and disapears
Script:
script.Parent.ThrowEvent.OnServerEvent:Connect(function(player, position, target)
if target.Parent.Name == "Dart Board" then
local dart = script.Parent.Handle:Clone()
local character = player.Character
dart.Name = "Dart"
dart.Transparency = 0
dart.Parent = game.Workspace
dart.CFrame = CFrame.new(dart.Position, position)
local velocity = Instance.new("BodyVelocity")
velocity.Parent = dart
velocity.Velocity = dart.CFrame.LookVector.Unit * 80
velocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
game.Debris:AddItem(velocity, 10)
dart.Touched:Connect(function(hit)
game.Debris:AddItem(dart, 20)
if velocity then
velocity:Destroy()
end
dart.Orientation = Vector3.new(90, 0, 0)
if not hit.Parent:FindFirstChildWhichIsA("Humanoid") and hit.CanCollide == true then
local weld = Instance.new("WeldConstraint")
weld.Parent = dart
weld.Part0 = dart
weld.Part1 = hit
dart.Massless = false
dart.CanCollide = false
end
end)
end
end)
Local Script:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
script.Parent.Activated:Connect(function()
script.Parent.ThrowEvent:FireServer(mouse.Hit.Position, mouse.Target)
end)
Tool layout: