Move and Rotate

Local Script

local folder = game.Workspace:WaitForChild('Movable')

local player = game.Players.LocalPlayer

local uis = game:GetService("UserInputService")

local mouse = player:GetMouse()


local rs = game:GetService('ReplicatedStorage')

local moveEvent = rs:WaitForChild('MoveEvent')

local rotateEvent = rs:WaitForChild('RotateEvent')


local selected


for _, part in pairs(folder:GetChildren()) do

if part:IsA('BasePart') then

part.ClickDetector.MouseClick:Connect(function()

selected = part

part.Transparency = 0.5

end)

end

end



uis.InputBegan:Connect(function(input)

if selected then

if input.UserInputType == Enum.UserInputType.MouseButton1 then

if (selected.Position - mouse.Hit.p).magnitude < 50 then

moveEvent:FireServer(selected, mouse.Hit.p)

selected.Transparency = 0

selected = nil

else

player.PlayerGui.ScreenGui.MoveError.Visible = true

wait(1)

player.PlayerGui.ScreenGui.MoveError.Visible = false

end

end

if input.UserInputType == Enum.UserInputType.MouseButton2 then

selected.Transparency = 0

selected = nil

end

if input.UserInputType == Enum.UserInputType.Keyboard then

if input.KeyCode == Enum.KeyCode.R then

rotateEvent:FireServer(selected)

end

end

end


end)

Script

local folder = script.Parent


local rs = game:GetService('ReplicatedStorage')

local moveEvent = rs:WaitForChild('MoveEvent')

local rotateEvent = rs:WaitForChild('RotateEvent')


local TweenService = game:GetService("TweenService")


local tweenInfo = TweenInfo.new(


2, --Time

Enum.EasingStyle.Linear, --Easing Style

Enum.EasingDirection.Out, --EasingDirection

0, --Repeat Count

false, --Reverse

0 --DelayTime

)


for _, part in pairs(folder:GetChildren()) do

if part:IsA('BasePart') then

local click = Instance.new('ClickDetector')

click.Parent = part

end

end


moveEvent.OnServerEvent:Connect(function(plr, part, mousePos)

local new_pos

if mousePos.Y < part.Size.Y / 2 then

new_pos = Vector3.new(mousePos.X, part.Size.Y / 2 , mousePos.Z)

else

new_pos = mousePos

end

local tween = TweenService:Create(part, tweenInfo, {Position = new_pos})

tween:Play()

end)


rotateEvent.OnServerEvent:Connect(function(plr, part)

part.Orientation = part.Orientation + Vector3.new(0,45,0)

end)