How do I scale my Gui up with TweenService after touching a part

Hello I am trying to make a GUI scale up when the player has touched a certain brick with tween service but so far my attempts have not worked.

local sign = game.StarterGui.Placeholder.Frame

local Tserv = game:GetService("TweenService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local activator = game.Workspace["Achivement Giver"] -- the brick the player touches to activate the tween
print("got stuff")
function GetAchv()
	
	sign.Size= UDim2.new(0,0,0,0)
	
	local Asize = {}
	Asize.Size = UDim2.new(0,747, 0, 366)
	
	local tween = Tserv:Create(sign,TweenInfo.new(0.5),Asize)
	
	sign.Visible = true
	tween:play()
	print("tweening")
	
	
end

function GetPlr(Atcv)
	local plr = Atcv.Parent
	if game.Players:GetPlayerFromCharacter(plr) then
		print("got playr")
		GetAchv()
		sign.Visible = true
		
	end
end

activator.Touched:Connect(GetPlr)
local players = game:GetService("Players")
local player = game.Players.LocalPlayer
local activator  game.Workspace:WaitForChild("PART_NAME_HERE") -- wait for your part
local sign = player:WaitForChild("PlayerGui"):WaitForChild("Placeholder"):WaitForChild("Frame") -- wait for your GUI


part.Touched:Connect(function(hit)
    --if already opened then return
    if sign.Visible then return end

    --check to see if it hit a body part OR accessory/tool Handle.
	local player = players:GetPlayerFromCharacter(hit.Parent) or players:GetPlayerFromCharacter(hit.Parent.Parent)

    if player then
        sign.Visible=true
        sign:TweenSize(UDim2.new(0,747, 0, 366), 0.5)
    end
end)

there was a few things wrong with your script.

You cannot use StarterGui in local scripts. (all gui is cloned from StarterGui and goes into the players PlayerGui)

You must use :WaitForChild() when using local scripts because some gui and parts may not exist yet when trying to grab them. (it takes a second for them to load onto the client sometimes)

you have to check to see if extra parts on the character were hit too, like tools or accessories. (depending on the case)

and lastly, it was probably easier to use the function provided by GuiObjects for tweening the size

1 Like

Adding onto what @codyorr4 said, if you are wanting the GUI to tween for ONLY the user who touched the part I’d also suggest using RemoteEvents and :FireClient(plr)

Thank you for your help. also sorry for not responding earlier I was busy with other stuff.

I also have 1 more question. is there a way for the GUI to expand from the center instead of 1 corner?

UDim2.new(0.5, 0, 0.5, 0) that would be the center of anyones screen. (50% of x and 50% of y)

Thank you and sorry for the late response

1 Like