I’m trying to make it so the cloned part flies directly towards the player’s mouse position, but it doesn’t seem to be working, as it is fired elsewhere instead. I don’t know what I should change to fix it as it seemed ok to me. Any suggestions?
game.ReplicatedStorage.Remotes.SendMousePosition.OnServerEvent:Connect(function(Player, MouseHitPosition, Clonable, HandlePos)
local Clone = Clonable:Clone()
Clone.Parent = workspace
local HasTouched = false
if Clone then
Clone.Name = Player.Name.."'s Clonable"
local distance = (MouseHitPosition - HandlePos).Magnitude
Clone.CFrame = CFrame.new(HandlePos, Clone.Position)
Clone.Velocity = Clone.CFrame.LookVector * 500
Clone.Touched:Connect(function(Hit)
if not HasTouched then
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= Player.Character then
Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
HasTouched = true
coroutine.resume(coroutine.create(function()
wait(10)
Clone:Destroy()
end))
end
end
end)
end
end)