Scale not working

im making animation gui gampass and when i open and close the scale is not workng well and the position change. please help me i tried everything.

script:

local GamepassId = 21177189 -- example

local frameToShow = script.Parent -- example

local player = game.Players.LocalPlayer
repeat wait() until player.Character -- waits for player to load in

local PlayerGui = player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui")
-- quote me if im wrong, but that should work

local MarketplaceService = game:GetService("MarketplaceService")
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
	frameToShow.Visible = true
end

local button = script.Parent
local frame = script.Parent.Parent.AnimationsBG
local debounce = false

button.MouseButton1Up:Connect(function()

	script.Parent.ClickSound:Play()

	if debounce == false then
		debounce = true

		frame.Visible = true

	elseif debounce == true then
		debounce = false

		frame.Visible = false

	end
end)

animation gui model: Animation Gui - Roblox

Well first of we don’t know what the scale is by scale do you mean the gui’s scale size? Or some sort of function you created yourself?

As for the position, do you mean to place the gui directly below the button or somewhere else?

If you could provide exactly what you’re trying to achieve here I might be able to offer some more advanced help.

Edit:
@sagiv200421

change this to

repeat game:GetService("RunService").Heartbeat:Wait() until player.Character

or just change it to this more cannon version.

local Character = player.Character or player.CharacterAdded:Wait()

wait() has a load of problems of itself if you use it so it’s better to just replace it with RunService.Heartbeat.