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

Getting a union to resize only by one face?

Asked by 5 years ago

I'm having trouble resizing a union via a script. I'm aware that a union's size must stay consistent and can't be squashed and stretched like a mesh, however, what I'm looking for is to replicate resizing a union like how you could using studio's resize tool, shown visually here.

I've tried the :Resize function that's inside BaseParts in order to resize just a singular face, but since a union's size needs to remain consistent, it didn't do anything differently. And I can't find a way to move the part backwards along with resizing, since the part in question is welded to a tool handle, and its position gets finicky. Any suggestions?

Here's the relevant script:

for i = 1, 20 do
        character.Battery.Value = character.Battery.Value - 1
        wait(1)
        local light = character.Flashlight.Handle2
        character.Flashlight.Handle2.Size = Vector3.new(light.Size.X, character.Battery.Value / 10, light.Size.Z)
end

1 answer

Log in to vote
1
Answered by
Vain_p 78
5 years ago
Edited 5 years ago

You could try to subtract the union to preform the operation then reunion it after your done via the functions UnionAsync(), and SubtractAsync() Beware these functions can only be executed on the server, it will error if you try the client

Also heres a quick example:

local part1 = Instance.new("Part",workspace)
part1.Anchored = true
local part2 = Instance.new("Part",workspace)
part2.Anchored = true

local union part1:UnionAsync({part2})

Ad

Answer this question