I have a script that Tweens the size of a GUI. The GUI Tweening script works at the time that I join, but when I reset my character and try to hold B to tween the GUI after resetting, nothing happens and I get two error message for the tweens.
"Can only tween objects in the workspace"
line 68 and 77
-- Script made by AltNature / Mr_Quarter#2828
-- // VARIABLES \\ --
local player = game.Players.LocalPlayer
local runservice = game:GetService("RunService")
local uis = game:GetService("UserInputService")
local runANIM = "http://www.roblox.com/asset/?id=2111751699"
local walkANIM = "http://www.roblox.com/asset/?id=2111623526"
local staminaBar = player.PlayerGui:WaitForChild("StaminaGui"):WaitForChild("NoStamina"):WaitForChild("behind"):WaitForChild("ImageLabel"):WaitForChild("bar")
local money = game.ReplicatedStorage.MoneyValue
local moneyDisplay = player.PlayerGui:WaitForChild("Money"):WaitForChild("ValueDisplay")
local breathBar = player.PlayerGui:WaitForChild("BreathGui"):WaitForChild("NoBreath"):WaitForChild("behind"):WaitForChild("ImageLabel"):WaitForChild("bar")
local check = true
-- // MONEY \\ --
runservice.RenderStepped:Connect(function()
moneyDisplay.Text = ('$'..money.Value)
end)
-- // BENEFITS TO DEVELOPERS \\ --
if player.Name == "AltNature" then
money.Value = 999999999
end
-- // FUNCTIONS \\ --
function increaseSpeed()
player.Character.Humanoid.WalkSpeed = 27
end
function decreaseSpeed()
player.Character.Humanoid.WalkSpeed = 16
end
function activateAnimation()
player.Character.Animate.run.RunAnim.AnimationId = runANIM
end
function deactivateAnimation()
player.Character.Animate.run.RunAnim.AnimationId = walkANIM
end
function tweenStaminaBar()
staminaBar:TweenSize(UDim2.new(0.854, 0,1, 0),
Enum.EasingDirection.In,
Enum.EasingStyle.Sine,
1,
true)
end
function normalStaminaBar()
wait(1)
staminaBar:TweenSize(UDim2.new(1,0,1,0),
Enum.EasingDirection.In,
Enum.EasingStyle.Sine,
3,
true
)
end
function tweenBreathBar()
breathBar.Visible = true
breathBar:TweenSize(UDim2.new(1, 0,1, 0),
Enum.EasingDirection.In,
Enum.EasingStyle.Sine,
6,
false
)
end
function normalBreathBar()
breathBar:TweenSize(UDim2.new(0,0,1,0),Enum.EasingDirection.In,
Enum.EasingStyle.Sine,3,true
) check = true
end
-- // EXECUTION \\ --
--/// Section 1, Sprinting \\\--
uis.InputBegan:Connect(function(input, gp)
if input.KeyCode == Enum.KeyCode.LeftShift then
if not gp then
increaseSpeed()
activateAnimation()
end
end
end)
uis.InputEnded:Connect(function(input, gp)
if input.KeyCode == Enum.KeyCode.LeftShift then
if not gp then
decreaseSpeed()
deactivateAnimation()
end
end
end)
--/// Section 2, Breathing \\\--
local check = true
uis.InputBegan:Connect(function(input, gp)
if input.KeyCode == Enum.KeyCode.B then
if not gp then
if check == true then
player.Character.Humanoid.WalkSpeed = 0
--/ / / Breathing requires some stamina \ \ \--
if staminaBar.Size == UDim2.new(1,0,1,0) then -- makes sure that the player
-- can't play with the tween
tweenStaminaBar() --subtract stamina a.k.a. make the bar's length
--shorter
normalStaminaBar() -- this takes 4 seconds.. the stamina recharges in
--this time
end
print("Stamina Bar Decreased.")
check = false
end
end
end
end)
uis.InputBegan:Connect(function(input, gp)
if input.KeyCode == Enum.KeyCode.B then
if not gp then
if breathBar.Size == UDim2.new(0,0,1,0) then
tweenBreathBar()
end
end
end
end)
uis.InputEnded:Connect(function(input,gp)
if input.KeyCode == Enum.KeyCode.B then
if not gp then
normalBreathBar()
player.Character.Humanoid.WalkSpeed = 16
end
end
end)
Help is appreciated, the script is located in StarterPlayerScripts and is a LocalScript

2 comments
ok named functions cringe me out too much so im not gonna even try help
what would you like me to do?