Sup,
I’m trying to make an dragging system for my game, but when using the dragdetector with following settings and script, it spins the model really fast.
Script
local Det = script.Parent
local Obj = Det.Parent.MovePart
local PosAtt = Instance.new("Attachment")
PosAtt.Parent = Obj
local AlignPos = Instance.new("AlignPosition")
AlignPos.Parent = Obj
AlignPos.Attachment0 = PosAtt
AlignPos.Enabled = false
AlignPos.Responsiveness = 100
local function GetLookAtt(plr): Attachment
local char = plr.Character
if not char then return end
local HRP = char:FindFirstChild("HumanoidRootPart")
if not HRP then return end
local Att = HRP:FindFirstChild("LookAtt")
if Att then
return Att
end
end
Det.DragStart:Connect(function(plr: Player)
local Att = GetLookAtt(plr)
if Att then
AlignPos.Attachment1 = Att
AlignPos.Enabled = true
Obj:SetAttribute("CurrentDrag", plr.UserId)
end
end)
Det.DragContinue:Connect(function(plr: Player, CursorRay: Ray, viewFrame: CFrame)
local Att = GetLookAtt(plr)
if Att then
local Y = viewFrame.LookVector.Y
Att.CFrame = CFrame.new(Vector3.new(0, (Y +5) + 1, -5))
end
end)
Det.DragEnd:Connect(function()
AlignPos.Enabled = false
AlignPos.Attachment1 = nil
Obj:SetAttribute("CurrentDrag", nil)
end)
Det:SetPermissionPolicyFunction(function(plr: Player, part: BasePart)
if not Obj:GetAttribute("CurrentDrag") then
return true
end
return false
end)
The Model is unanchored.