Log in to vote

how to change script from move tool to scale tool?

Asked by 8 days ago

i have this script for move tool (for placement system), when model is outside of base, it will be red and i wont be able to place it. i want scale tool for walls, floors. it will contain more parts in model and i have no idea how to even scale one part with scale tool script. can someone help me?

local cframe =
    cframe = script.Parent.Adornee.CFrame

script.Parent.MouseDrag:Connect(function(face, distance)
    distance = math.round(distance/1) * 1
    local base = script.Parent.Adornee.Parent.Parent.Parent.Parent
    if base then
        if (script.Parent.Adornee.Parent:SetPrimaryPartCFrame(cframe **distance))) ~= nil then
            script.Parent.Adornee.CFrame = script.Parent.Adornee.Parent:SetPrimaryPartCFrame(cframe **distance))
        local ownmin = (script.Parent.Adornee.Position - script.Parent.Adornee.Size/2)
        local ownmax = (script.Parent.Adornee.Position + script.Parent.Adornee.Size/2)
        local min = ((base.Position - base.Size/2) +, 1, 0))
        local max = ((base.Position + base.Size/2) +, 50, 0))
        local part1 = (ownmin.X <= max.X and ownmax.X <= max.X and ownmin.X >= min.X and ownmax.X >= min.X)
        local part2 = (ownmin.Z <= max.Z and ownmax.Z <= max.Z and ownmin.Z >= min.Z and ownmax.Z >= min.Z)
        local part3 = (ownmin.Y <= max.Y and ownmax.Y <= max.Y and ownmin.Y >= min.Y and ownmax.Y >= min.Y)
        if part1 and part2 and part3 then
            require(game:GetService("ReplicatedStorage").Placement):isColliding(script.Parent.Adornee.Parent, "Yes")
        elseif ownmin.X > max.X or ownmin.Z > max.Z or ownmin.Y > max.Y then
            script.Parent.Adornee.BrickColor ="Really red")
        elseif ownmax.X > max.X or ownmax.Z > max.Z or ownmax.Y > max.Y then
            script.Parent.Adornee.BrickColor ="Really red")
        elseif ownmin.X < min.X or ownmin.Z < min.Z or ownmin.Y < min.Y then
            script.Parent.Adornee.BrickColor ="Really red")
        elseif ownmax.X < min.X or ownmax.Z < min.Z or ownmax.Y < min.Y then
            script.Parent.Adornee.BrickColor ="Really red")

Answer this question