So, Today I wanted to make a move system. But It’s kinda glitched
–I can’t upload the Video so It’s hard to understand–
The Code
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Side = "Nil"
script.Parent.MouseButton1Down:Connect(function(Id)
if Id == Enum.NormalId.Left then
Side = "-X"
else
Side = "Nil"
end
end)
script.Parent.MouseDrag:Connect(function(Id,Size)
if Id == Enum.NormalId.Left then
Side = "-X"
else
Side = "Nil"
end
if Side == "-X" then
local Size2 = math.floor(Size)
print(Size2,Size,Id)
game.Workspace.Prototype.Position = Vector3.new(game.Workspace.Prototype.Position.X - Size2,game.Workspace.Prototype.Position.Y,game.Workspace.Prototype.Position.Z)
end
end)
I also tried Removing math.floor() but it still didn’t work.
If I hold on the handles It will move weirdly with delays and it will fly out of map.
I actually have the implementations of all of them saved.
Resize:
local Handle = script.Parent
local Increment = 0
local Previous
local function CustomResize(Part,NormalID,Delta)
local Normal = Vector3.FromNormalId(NormalID)
local Invert = Normal.X+Normal.Y+Normal.Z
local NewSize = Part.Size + (Normal * Delta * Invert)
if ((NewSize.X < 0.05) or (NewSize.Y < 0.05) or (NewSize.Z < 0.05)) then return end
Part.Size = NewSize
Part.CFrame *= CFrame.new(Normal * Delta * 0.5)
return true
end
Handle.MouseButton1Down:Connect(function()
Previous = 0
end)
Handle.MouseDrag:Connect(function(NormalID,Distance)
if (Increment ~= 0) then
Distance = ( math.floor( Distance / Increment + 0.5 ) * Increment )
end
if (not CustomResize( Handle.Adornee, NormalID, ( Distance - Previous ) )) then return end
Previous = Distance
end)
Rotate (Note: For rotate you will need to use ArcHandles.):
local Handle = script.Parent
local Increment = math.rad(
0 -- In Degrees
)
local PreviousAngle
Handle.MouseButton1Down:Connect(function()
PreviousAngle = 0
end)
Handle.MouseDrag:Connect(function(Axis,Angle,Radius)
if (Increment ~= 0) then
Angle = ( math.floor( Angle / Increment + 0.5 ) * Increment )
end
Handle.Adornee.CFrame *= CFrame.fromAxisAngle( Vector3.fromAxis(Axis), (Angle-PreviousAngle) )
PreviousAngle = Angle
end)