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
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)