The Enums or the index were supposed to be in brackets which I forgot which I usually think it will be the other way around. – The new one has since been edited but for an explanation always put the line before the equals in brackets – { [Enum.Example.Eg] = ‘X’ } right here the item before equal is put in brackets.
Can you give the correct code thne? I don’t really understand your statements.
Even when the left handle is dragged, it goes right. This applies to the other handles of each axis as well.
Oh well you shouldn’t be using the position as part of it because it will move it around, hence the reason why you are using it to grow on both sides it shouldn’t move.
No the intended outcome is that it doesn’t scale on both sides. Also I want to put a 1 increment.
Could you add in a bool that prevents the increments from going too much? Like for instance, when it goes 1 incriment, it must wait .5 seconds before the next one can be made.
You could also make it so you need to be near the edge of the part to change the size (such as being within 75-100 studs of the edge of the part? This way, it won’t fling out into no where because it will stop it from becoming too big at once
Well scaling happens on both sides you would have to use CFrame
and use this instead:
local scaleHandle = script.Parent
local block = workspace[script.Parent.Adornee.Name]
local ChoseIncrement = 1 -- Of your choosing
scaleHandle.MouseDrag:Connect(function(face, distance) -- example : distance is 4.62
local NormalVector = Vector3.fromNormalId(face)
local ReadDiffrence = distance / ChoseIncrement -- example : 4.62 / 1 = 4.62
local Remainder = distance % ChoseIncrement -- need this for the increment , example: remainder: 0.62
local Different = Remainder / ChoseIncrement -- helps to subtract from the ReadDifference, example : 0.62/1 = 0.62
local Increment = ReadDifference - Different -- example : 4.62 - 0.62 = 4
block.Size += NormalVector * Increment
local NewPoint = NormalVector * (Increment/2)
block.CFrame = block.CFrame * CFrame.new( NewPoint )
end)
It’s a bit buggy
Are you still there? Its been a while.
Here is the code I have so far.
I have just done something like this for a game I am working on. It basically detects if the object is at the edge of the screen. If it is, it makes the object move towards the center of the screen.
local screenSize = workspace.CurrentCamera.ViewportSize – Get current screen size
local screenCenter = screenSize / 2 – Divide the screen size by 2 to get the center
local boxSize = box.Size – Get the size of the box
local boxCenter = box.CFrame.p – Get the center of the box
if boxCenter.X >= screenSize.X + boxSize.X / 2 then – If the box is on the right side of the screen
box.CFrame = box.CFrame * CFrame.new(-0.1, 0, 0) – Move the box towards the center of the screen (left)
end
if boxCenter.X <= -(boxSize.X / 2) then – If the box is on the left side of the screen
box.CFrame = box.CFrame * CFrame.new(0.1, 0, 0) – Move the box towards the center of the screen (right)
end
if boxCenter.Y >= screenSize.Y + boxSize.Y / 2 then – If the box is on the top side of the screen
box.CFrame = box.CFrame * CFrame.new(0, -0.1, 0) – Move the box towards the center of the screen (down)
end
if boxCenter.Y <= -(boxSize.Y / 2) then – If the box is on the bottom side of the screen
box.CFrame = box.CFrame * CFrame.new(0, 0.1, 0) – Move the box towards the center of the screen (up)
end
Simply add half the incrementVector to the position
So that it increases both sides but it moves the part half the whole increment to the “top” and patches this effect