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

How to resize accessory upwards only?

Asked by 2 years ago

So I have a backpack and each time a player picks an item up the backpack get bigger upwards, the thing is it get bigger upwards and downwards, I guess because of the attachment of the accessory???

Here's the script for the backpack to get bigger

script.Parent.Touched:Connect(function(hit)
    if hit and hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
        local Team = game:GetService("Teams")
        local ReplicatedStorage = game:GetService("ReplicatedStorage")
        local Resize = require(ReplicatedStorage.Resize)
        local PINK = Team.Pink
        local pinkblock = hit.Parent.PINKBLOCK
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player.Team == PINK  then
            script.Parent["Click Sound"]:Play()
            print("resized")
            Resize(pinkblock.Handle, Enum.NormalId.Top, 2.239)
            script.Parent:Destroy()
        else
            print("didnt resize")
        end
    end
end)

Here's the module:

local NORMAL_DIRECTIONS = {
    [Enum.NormalId.Top] = Vector3.new(0, 1, 0);
    [Enum.NormalId.Bottom] = Vector3.new(0, -1, 0);
    [Enum.NormalId.Back] = Vector3.new(0, 0, 1);
    [Enum.NormalId.Front] = Vector3.new(0, 0, -1);
    [Enum.NormalId.Right] = Vector3.new(1, 0, 0);
    [Enum.NormalId.Left] = Vector3.new(-1, 0, 0);
}

return function(part, normal, delta)
    local Direction = NORMAL_DIRECTIONS[normal]
    part.Size = part.Size + Vector3.new(math.abs(Direction.X), math.abs(Direction.Y), math.abs(Direction.Z))*delta
    part.CFrame = part.CFrame + NORMAL_DIRECTIONS[normal]*delta/2
end

Can anyone help me?

1 answer

Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Ad

Answer this question