Basically im trying to make a part go where the mouse is but then the mouse goes on top of the part and the part keeps going upwards trying to catch up with the mouse and etc, how do i stop that:
local rs = game:GetService("RunService")
rs.Stepped:Connect(function()
if game:GetService("UserInputService"):IsMouseButtonPressed(Enum.UserInputType.MouseButton1) then
local filtered = {game.Players.LocalPlayer.Character}
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = filtered
local pos = game:GetService("UserInputService"):GetMouseLocation()
local WorldToScreenPoint = workspace.CurrentCamera:ViewportPointToRay(pos.X, pos.Y)
local ray = workspace:Raycast(WorldToScreenPoint.Origin, WorldToScreenPoint.Direction*100, params)
if ray and ray.Instance then
if ray.Instance:IsA("Part") and ray.Instance.Name ~= "Baseplate" then
ray.Instance.Position = ray.Position
end
end
end
end)