Hi, so basically my question is how does bloxburg sizes parts when the mouse is moved? I made a topic like 15-16 hours ago but that wasn’t clear, and now there are no people replying. I am hoping for help! Please Here’s the video of how it works now:
robloxapp-20201002-0306308.wmv (583.5 KB)
It’s scaling on both sides, if you see in the studio when you scale a part while holding shift, it’s scaling on both sides and I don’t want that
What are you trying to achieve? Can you send a video from how it looks on Bloxburg.
Ok hold on, let me tell you what I am looking for, not exactly like bloxburg, but here’s a topic, see the vid:
Hello, this is my first approach:
Put in localscript in StarterPlayer => StarterCharacterScripts
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local RunService = game:GetService("RunService") --we will use this service for something later
local target
local down
local wall = Instance.new('Part', game.Workspace)
wall.Material = Enum.Material.Brick
wall.Anchored = true
local s = Instance.new('Part', game.Workspace)
s.Shape = Enum.PartType.Ball
s.Transparency = 0.5
s.Color = Color3.new(1, 0, 0)
s.Anchored = true
s.CanCollide = false
local startPosition
local endPosition
mouse.Button1Down:connect(function()
if mouse.Target ~= nil then
target = mouse.Target
mouse.TargetFilter = target
down = true
end
end)
game:GetService("RunService").RenderStepped:Connect(function() --replaced the move event with renderstepped because it works better in some cases, renderstepped is an event that fires every frame, basically super fast, look it up it is important!
s.Position = mouse.Hit.Position
if down == true and target ~= nil then
if not startPosition then
startPosition = mouse.Hit.Position
end
endPosition = mouse.Hit.Position
wall.CFrame = CFrame.new(startPosition, endPosition)
wall.Position = (startPosition + endPosition) / 2 + Vector3.new(0, 2, 0)
local diff = endPosition - startPosition
wall.Size = Vector3.new(0.1, 4, math.sqrt(math.pow(diff.X, 2) + math.pow(diff.Z, 2)))
end
end)
mouse.Button1Up:connect(function()
startPosition = nil
down = false
mouse.TargetFilter = nil
target = nil
end)
Ok, this is better:
local player = game.Players.LocalPlayer
local workspaceService = game:GetService("Workspace")
local RunService = game:GetService("RunService")
local userInputService = game:GetService("UserInputService")
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local target
local down
local wall = Instance.new('Part', game.Workspace)
wall.Material = Enum.Material.Brick
wall.Anchored = true
local startPosition
local endPosition
local function getMouseHit(ignoreList)
local mouseLocation = userInputService:GetMouseLocation()
local viewportPointRay = camera:ViewportPointToRay(mouseLocation.X, mouseLocation.Y)
local extendedRay = Ray.new(viewportPointRay.Origin, viewportPointRay.Direction * 1000)
return workspaceService:FindPartOnRayWithIgnoreList(extendedRay, ignoreList)
end
mouse.Button1Down:connect(function()
if mouse.Target ~= nil then
target = mouse.Target
mouse.TargetFilter = target
down = true
end
end)
game:GetService("RunService").RenderStepped:Connect(function() --replaced the move event with renderstepped because it works better in some cases, renderstepped is an event that fires every frame, basically super fast, look it up it is important!
if down == true and target ~= nil then
local _, p = getMouseHit({wall})
if not startPosition then
startPosition = p
end
endPosition = p
wall.CFrame = CFrame.new(startPosition, endPosition)
wall.Position = (startPosition + endPosition) / 2 + Vector3.new(0, 2, 0)
local diff = endPosition - startPosition
wall.Size = Vector3.new(0.1, 4, math.sqrt(math.pow(diff.X, 2) + math.pow(diff.Z, 2)))
end
end)
mouse.Button1Up:connect(function()
local new_wall = wall:Clone()
new_wall.Parent = wall.Parent
startPosition = nil
down = false
mouse.TargetFilter = nil
target = nil
end)
Sorry “FindPartOnRayWithIgnoreList” is deprecated. You can use “Raycast”. I have add a red ball for mark.
local player = game.Players.LocalPlayer
local workspaceService = game:GetService("Workspace")
local RunService = game:GetService("RunService")
local userInputService = game:GetService("UserInputService")
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local target
local down
local wall = Instance.new('Part', game.Workspace)
wall.Material = Enum.Material.Brick
wall.Anchored = true
local startPosition
local endPosition
local s = Instance.new('Part', game.Workspace)
s.Shape = Enum.PartType.Ball
s.Material = Enum.Material.SmoothPlastic
s.Color = Color3.new(1, 0, 0)
s.Transparency = 0.5
s.Size = Vector3.new(0.5, 0.5, 0.5)
-- for intercept the baseplate
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.FilterDescendantsInstances = {workspace.Baseplate}
raycastParams.IgnoreWater = true
-- Grid size
local grid = 4
function round(x, n)
n = math.pow(10, n or 0)
x = x * n
if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
return x / n
end
function calculate_position(pos, grid)
return Vector3.new(round(pos.X / grid, 0) * grid, pos.Y, round(pos.Z / grid, 0) * grid)
end
local function getMouseHit()
-- Calculate the position of intercept with baseplate
local mouseLocation = userInputService:GetMouseLocation()
local viewportPointRay = camera:ViewportPointToRay(mouseLocation.X, mouseLocation.Y)
local raycastResult = workspace:Raycast(viewportPointRay.Origin, viewportPointRay.Direction * 1000, raycastParams)
local position = Vector3.new(0,0,0)
if raycastResult then
position = raycastResult.Position
end
return position
end
mouse.Button1Down:connect(function()
if mouse.Target ~= nil then
target = mouse.Target
mouse.TargetFilter = target
down = true
end
end)
game:GetService("RunService").RenderStepped:Connect(function() --replaced the move event with renderstepped because it works better in some cases, renderstepped is an event that fires every frame, basically super fast, look it up it is important!
local p = getMouseHit()
p = calculate_position(p, grid)
s.Position = p
if down == true and target ~= nil then
if not startPosition then
startPosition = p
end
endPosition = p
wall.CFrame = CFrame.new(startPosition, endPosition)
wall.Position = (startPosition + endPosition) / 2 + Vector3.new(0, 3, 0)
local diff = endPosition - startPosition
wall.Size = Vector3.new(0.5, 6, math.sqrt(math.pow(diff.X, 2) + math.pow(diff.Z, 2)))
end
end)
mouse.Button1Up:connect(function()
local new_wall = wall:Clone()
new_wall.Parent = wall.Parent
startPosition = nil
down = false
mouse.TargetFilter = nil
target = nil
end)