changing the increment for a custom resize tool?
Asked by
5 years ago Edited 5 years ago
I am having trouble changing the increment for a resize tool I adapted for my project.
001 | local tool = script.Parent |
002 | local plr = game.Players.LocalPlayer |
003 | local mouse = plr:GetMouse() |
008 | local previousDistance |
010 | local buttonupconnection |
013 | function onHandlesDown(normal) |
019 | function onHandlesDrag(normal, distance) |
020 | if handles.Adornee then |
021 | local delta = distance - previousDistance |
022 | if math.abs(delta) > = handles.Adornee.ResizeIncrement then |
023 | local sizeDelta = math.floor(delta / handles.Adornee.ResizeIncrement + 0.5 ) * handles.Adornee.ResizeIncrement |
024 | if handles.Adornee:Resize(normal, sizeDelta) then |
025 | previousDistance = distance |
027 | buttonupconnection = mouse.Button 1 Up:connect( function ()onButton 1 Up(mouse,handles.Adornee) end ) |
037 | function onButton 1 Up(mouse,part) |
038 | if part and script.Parent.Parent = = plr.Character then |
039 | local size = part.Size |
040 | local cfr = part.CFrame |
041 | script.Parent.PartChange:FireServer(originalpart,size,cfr) |
048 | function onButton 1 Down(mouse) |
049 | local findpart = game.ReplicatedStorage.BuildingParts:FindFirstChild(mouse.Target.Name) |
053 | if mouse.Target = = nil or mouse.Target.Locked or not findpart then |
055 | selectionBox.Adornee = nil |
056 | selectionLasso.Part = nil |
057 | handles.Adornee = nil |
060 | originalpart = mouse.Target |
061 | tempart = findpart:Clone() |
062 | tempart.CanCollide = false |
063 | tempart.Anchored = true |
064 | tempart.Transparency = 0.6 |
065 | tempart.Size = originalpart.Size |
066 | tempart.Parent = game.Workspace |
067 | tempart.CFrame = originalpart.CFrame |
068 | tempart.BrickColor = BrickColor.new( "Lime green" ) |
069 | selectionBox.Adornee = tempart |
070 | selectionLasso.Part = tempart |
071 | handles.Adornee = tempart |
072 | handles.Faces = tempart.ResizeableFaces |
079 | function onEquippedLocal(mouse) |
080 | mouse.Button 1 Down:connect( function () onButton 1 Down(mouse) end ) |
082 | local character = script.Parent.Parent |
083 | local player = game.Players:GetPlayerFromCharacter(character) |
085 | selectionBox = Instance.new( "SelectionBox" ) |
086 | selectionBox.Color = BrickColor.Blue() |
087 | selectionBox.Adornee = nil |
088 | selectionBox.Parent = player.PlayerGui |
090 | selectionLasso = Instance.new( "SelectionPartLasso" ) |
091 | selectionLasso.Name = "Model Delete Lasso" |
092 | selectionLasso.Humanoid = character.Humanoid |
093 | selectionLasso.Parent = game.workspace |
094 | selectionLasso.Part = nil |
095 | selectionLasso.Visible = true |
096 | selectionLasso.archivable = false |
097 | selectionLasso.Color = BrickColor.Red() |
099 | handles = Instance.new( "Handles" ) |
100 | handles.Color = BrickColor.Blue() |
101 | handles.Adornee = nil |
102 | handles.MouseDrag:connect(onHandlesDrag) |
103 | handles.MouseButton 1 Down:connect(onHandlesDown) |
104 | handles.Parent = player.PlayerGui |
107 | function onUnequippedLocal() |
108 | selectionBox:Destroy() |
109 | selectionLasso:Destroy() |
111 | if handles.Adornee then |
112 | handles.Adornee:Destroy() |
114 | if buttonupconnection then |
115 | buttonupconnection:Disconnect() |
120 | tool.Equipped:connect(onEquippedLocal) |
121 | tool.Unequipped:connect(onUnequippedLocal) |
the current function that I am concerned about is onhandlesdrag. I tried changing various things such as handles.adornee.sizeincrement.
I tried changing sizedelta up but that didnt work.
I want to change the increment to 0.5, but any attempts that didn't end in failure only ended in the part resizing 1 stud.