I am making a game like Mashables. There is a building, rotating, moving, and sizing system you can do with objects in Mashables to make robots. I am trying to replicate this in my game. I have decided to start with the sizing system, and it is acting odd.
Here is the problem: It seems like the block is scaling from both sides, and when I scale it to the edge of the screen, it scales very largely. I want to implement an increment.
local scaleHandle = script.Parent
local block = workspace[script.Parent.Adornee.Name]
scaleHandle.MouseDrag:Connect(function(face, distance)
if face == Enum.NormalId.Left or face == Enum.NormalId.Right then
block.Size += Vector3.new(distance, 0, 0)
end
if face == Enum.NormalId.Top or face == Enum.NormalId.Bottom then
block.Size += Vector3.new(0, distance, 0)
end
if face == Enum.NormalId.Front or Enum.NormalId.Back then
block.Size += Vector3.new(0, 0, distance)
end
end)
local scaleHandle = script.Parent
local block = workspace[script.Parent.Adornee.Name]
scaleHandle.MouseDrag:Connect(function(face, distance)
if face == Enum.NormalId.Left or face == Enum.NormalId.Right then
block.Size += Vector3.new(distance, 0, 0)
block.Position += Vector3.new(distance / 2, 0, 0)
end
if face == Enum.NormalId.Top or face == Enum.NormalId.Bottom then
block.Size += Vector3.new(0, distance, 0)
block.Position += Vector3.new(0, distance / 2, 0)
end
if face == Enum.NormalId.Front or Enum.NormalId.Back then
block.Size += Vector3.new(0, 0, distance)
block.Position += Vector3.new(0, 0, distance / 2)
end
end)
I can’t find the documentation for the MouseDrag event you’re using anywhere. I need to know if distance is always positive or negative relative to the face, or relative to the part’s local space.
Your code seems to assume that the distance will be relative to the part’s CFrame, so pulling out the front face would be a negative distance, and pulling the back face would be a positive. It doesn’t look like that’s correct though.
Oh I believe you have to put them in brackets or they have to be in the same line which I didn’t do because I wasn’t able to see everything. Also there isn’t any negatives in my script the back on yours has a negative remove that as well.
You don’t need the back and front to be alter they want it to go on both sides they have to be the same on each side but I believe you mean from the position.