You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make resize building system with increment and sizes one face when u click on handle -
What is the issue? Include screenshots / videos if possible!
It can’t to be stopped targetting, and it given by Assistant, but it didn’t helped me. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Yes, I looked everywhere I found some solutions, but i didn’t know how to edit them in local scripts.
Here’s my code of building resizing system script.
Local script:
local cframeAtMouseDown, sizeAtMouseDown, lastGoalSize
local Mouse = player:GetMouse()
local part
-- Connect the Handles object to the MouseButton1Down event
RunService.RenderStepped:Connect(function() -- Runs every frame, aka 24/7
if mode == "Place" then
local target = buildBase.mouseTarget()
if target then
ghostPart.Position = buildBase.mouseGridPosition()
ghostPart.Orientation = buildBase.getSmoothOrientation()
ghostPart.Parent = workspace
else
ghostPart.Parent = nil
end
buildOutline.Adornee = ghostPart
else
ghostPart.Parent = nil
buildOutline.Adornee = nil
end
if mode == "Delete" then
local target = buildBase.mouseTarget()
deleteOutline.Adornee = target
else
deleteOutline.Adornee = nil
end
if mode == "Resize" then
local target = buildBase.mouseTarget()
handles.Adornee = target
else
handles.Adornee = nil
end
end)
UserInputService.InputBegan:Connect(function(input, processed)
if processed then
return
end
if canBuildValue.Value then
if input.KeyCode == Enum.KeyCode.Q then -- Checks if key is Q
if mode == "Spectate" then
mode = "Place"
elseif mode == "Place" then
mode = "Resize"
elseif mode == "Resize" then
mode = "Delete"
else
mode = "Spectate"
end
updateMode()
elseif input.KeyCode == Enum.KeyCode.R then
buildBase.rotate()
elseif input.KeyCode == Enum.KeyCode.T then
buildBase.tilt()
elseif input.KeyCode == Enum.KeyCode.F then
previousBlockType()
elseif input.KeyCode == Enum.KeyCode.G then
nextBlockType()
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
if mode == "Place" then
placeBlock()
elseif mode == "Delete" then
deleteBlock()
end
local connection
if mode == "Resize" then
connection = handles.MouseButton1Down:Connect(function()
-- Code to handle resizing when the Handles object is clicked
local part = Mouse.Target
if part and part ~= nil and mode == "Resize" then
local originalSize = part.Size
local originalMousePosition = Vector2.new(Mouse.X, Mouse.Y)
local function resize()
local delta = Vector2.new(Mouse.X, Mouse.Y) - originalMousePosition
local newSize = originalSize + Vector3.new(delta.X, 0, delta.Y)
part.Size = newSize
end
local function stopResize()
-- Fire a server event to apply the size changes
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage.Events:FindFirstChild("ResizeBlock")
remoteEvent:FireServer(part.Size)
part = nil
connection:Disconnect()
Mouse.Move:Disconnect()
end
handles.MouseButton1Up:Connect(stopResize)
Mouse.Move:Connect(resize)
end
end)
else
if connection then
connection:Disconnect()
end
end
elseif input.KeyCode == Enum.KeyCode.LeftAlt then
local target = buildBase.mouseTarget()
if target and target.Parent == workspace.Blocks then
color = target.Color
canCollide = target.CanCollide
SelectedMaterial = target.Material
transparency = target.Transparency
if target:FindFirstChild("PointLight") then
light = target.PointLight.Range
else
light = 0
end
updateGhostPart()
updateProperties()
local extraParam = canCollide and "true" or "false"
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
Text = "Color: ".. target.BrickColor.Name.."; CanCollide: ".. extraParam.."; Material: ".. target.Material.Name.."; Light: ".. light .."; Transparency: "..transparency,
Color = Color3.fromRGB(100,100,100),
Font = Enum.Font.ArialBold,
FontSize = Enum.FontSize.Size24
})
end
end
end
end)
Server Script:
local resizeBlock = game.ReplicatedStorage.Events.ResizeBlock
-- Define the callback function for the server event
local function applySize(part, newSize)
-- Check if the part is valid and the newSize is within the desired range
if part and newSize.X >= 2 and newSize.Y >= 2 and newSize.Z >= 2 then
part.Size = newSize
end
end
-- Connect the callback function to the server event
resizeBlock.OnServerEvent:Connect(applySize)