How do I make a gui tween when you touch a part

Hi,

So the title pretty much says it all. I have tired to do it for the past hour but it still doesn’t work.

From,
File

Use a remote event. for example:

local Rep = game.ReplicatedStorage
local RemoteEvent = Rep.RemoteEvent

local Part = script.Parent

Part.Touched:Connect(function(otherPart)
      local Player = game.Players:GetPlayerFromCharacter(otherPart.Parent)

      if Player then
      RemoteEvent:FireClient(Player)
   end
end)

and then make a LocalScript inside StarterGui (or whatever) then do:

local Rep = game.ReplicatedStorage
local RemoteEvent = Rep.RemoteEvent

RemoteEvent.OnClientEvent:Connect(function()
      -- Do Something
end)

Note: Change ReplicatedStorage into the location of the RemoteEvent

local part = script.Parent
local ts = game:GetService("TweenService")
local debounce = false

part.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		local plrGui = plr:FindFirstChild("PlayerGui")
		if plrGui then
			debounce = true
			local screenGui = plrGui.ScreenGui
			local frame = screenGui.Frame
			local tween = ts:Create(frame, TweenInfo.new(0.5), {Size = UDim2.new(0, 200, 0, 200)})
			tween:Play()
			tween.Completed:Wait()
			debounce = false
		end
	end
end)

Relatively primitive but this will double the size (using a tween) of a default Frame instance when the BasePart instance the script is parented to is touched by a player.

image

image

https://gyazo.com/1085a040702d759d2cb367057cc1ae43

oh wait. For some reason it only works once.

frame.Size = UDim2(0, 100, 0, 100)

Yeah, if you need it to re-perform the tween then you need to revert the GuiObject instance back to its original/some different state. You can add the line above after “debounce = false”.

I have a button so when you click it it goes back to its original state.

https://gyazo.com/884924c203b2c0050647777ca4079a6a