Here's whats wrong and how you can fix it:
So what's wrong? Well, you're referencing to GUI as game.StarterGui.Stamina.Super.Bar. This is the GUI that is "given" to all players when they join, but the one given to them is a clone, not the actual GUI itself. If you tried to change the actual GUI itself, it will only apply when they reset, and even then, it's not going to work because the GUI resets on death (which is something you can turn off in properties).
So how do you fix it?
Well, first off, you're not tweening it. You're simply setting it's size. What you want to do is use the TweenSize method of GUIs. So GUI:TweenSize(UDim2Size, EasingDirection, EasingStyle).
Second, you want to make sure to reference to the correct GUI, the one the current player has.
https://developer.roblox.com/en-us/api-reference/function/GuiObject/TweenSize
Here is a fixed script:
local p = game.Players.LocalPlayer
local pgui = p:WaitForChild("PlayerGui")
local userInputService = game:GetService("UserInputService")
local GUI = pgui.Stamina.Super.Bar
userInputService.InputBegan:Connect(function(input, gameProc)
if input.KeyCode == Enum.KeyCode.G and not gameProc then
script.Parent.Text = "State: Super"
GUI:TweenSize(UDim2.new(0, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, 1, true);
wait(5)
script.Parent.Text = "State: Normal"
GUI:TweenSize(UDim2.new(1, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, 1, true)
end
end)
1 comment
Please include what type of script it is and where it is located. It would be happily apreciated if you could include any eventual errors aswell.