Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Part resizing on both all sides and not the side you are resizing why?

Asked by 6 years ago

So why is this script making so the part is resizing on both sides on the part when you do the X and Z axis, I tried to make the wall resize like welcome to bloxburg but it just resizes on the both ends of the part. I want it to resize only on the Z axis if you are resizing on the Z axis but only one side of the part that you are trying to resize and let it stay in the same position it is in but resize it.

Here is the local script:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local part = workspace.laser

local sizing = false

while mouse.Button1Down do
    sizing = true
    local x,y,z = mouse.hit.x, mouse.hit.y, mouse.hit.z
    part.Size = Vector3.new(math.floor(x), 1, math.floor(z))
    wait()
end

mouse.Button1Up:connect(function()
    sizing = false
end)

spawn(function()
    print(sizing)
    while not sizing do
        local x,y,z = mouse.hit.x, mouse.hit.y, mouse.hit.z

        part.Position = Vector3.new(math.floor(x),math.floor(y),math.floor(z))
        wait()
    end
end)
0
I dont like the resize function. It doesn't have a parameter to ignore parts on that side you want to resize on. hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You can change the part's CFrame to an offset of half the mouse's hit.

For example, if the part's size increases by 2.6 studs on its Z axis, it will go to the right by 1.3 studs. Therefore it won't resize on both sides.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local part = workspace.laser

local OriginalPosition = part.CFrame --This sets the part's original position so we can set the offset later.

local sizing = false

while mouse.Button1Down do
    sizing = true
    local x,y,z = mouse.hit.x, mouse.hit.y, mouse.hit.z
    part.Size = Vector3.new(math.floor(x), 1, math.floor(z))
    part.CFrame = OriginalPosition + Vector3.new(math.floor(x)/2, 0, math.floor(z)/2)
    wait()
end

mouse.Button1Up:connect(function()
    sizing = false
end)

spawn(function()
    print(sizing)
    while not sizing do
        local x,y,z = mouse.hit.x, mouse.hit.y, mouse.hit.z

        part.Position = Vector3.new(math.floor(x),math.floor(y),math.floor(z))
    part.CFrame = OriginalPosition + Vector3.new(math.floor(x)/2, 0, math.floor(z)/2)
        wait()
    end
end)

~SkeletalReality

0
But line 13 makes the park move like a placement system the part should get stuck in the position it is when you hold the mousebutton1down and move the part around when you aren't holding it down ObStactionD3stroy3r 14 — 6y
0
like part.CFrame = OriginalPosition + Vector3.new(.5, 0, .5) why isn't that working? ObStactionD3stroy3r 14 — 6y
Ad

Answer this question