Ad
Log in to vote
0

How would I go about fixing Handles movement?

Asked by 4 days ago

Hi, I think most acknowledged scripters of this place know about "Handles" instance, right? I've been testing some stuff with it to make movable part in-game (Just like Studio's part movement). And it works, pretty much. I used if face == Enum.NormalId.Back/Front/Etc then method and I thought that it was waaay to long so I decided to shorten it in 4-5 lines instead of using 6 elseifs. I found out how I possibly could do it and it worked but not as it should.

local H = Instance.new("Handles")

function Snap(Pos)
    return Vector3.new((math.floor(Pos.X / Grid + 0.5) * Grid),(math.floor(Pos.Y / Grid + 0.5) * Grid),(math.floor(Pos.Z / Grid + 0.5) * Grid))
end

H.MouseDrag:Connect(function(face,dist)
    local Vect = Vector3.FromNormalId(face) * Vector3.new(dist,dist,dist)
    local NewPos = Vect

    --if face == Enum.NormalId.Front then
    --  NewPos = Vector3.new(0,0,dist)
    --end

    t.Position = Snap(t.Position + NewPos)
end)

The problem of this script is, it moves the part. But each time you move mouse further, it moves part faster and faster. My theory is it for some reason multiplies distance by distance when it just should multiply it by the face. I have no other theory and I have no idea how I could fix it so I'm asking people over there.

It's known that Snap function doesn't causes this problem so don't dig in it for your own sanity, the problem is Vect variable.

Answer this question