This is the script I'm using.
local player = game.Players
local localplayer = player.LocalPlayer
local Frame = script.Parent.Frame.Frame
local StaminaMax = 100
local StaminaMin = 5
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
player.PlayerAdded:Connect(function(player)
local Stats = Instance.new("Folder", localplayer)
Stats.Name = "Stats"
local Stamina = Instance.new("IntValue", Stats)
Stamina.Name = Stamina
Stamina.Value = 100
while Enum.HumanoidStateType.Running == true do
wait(0.4)
Stamina.Value = Stamina.Value - 5
Frame.Size = UDim2.new(Stamina.Value/StaminaMax, 0, 1, 0)
end
if Stamina.Value <= StaminaMin then
humanoid:ChangeState(Enum.HumanoidStateType.None)
end
end)
The output doesn't recognise this script, and I'm not even getting an error. If you have any solution, please share it with me. Thanks in advance.

4 comments
Would you mind posting an example?
Where is the local Script located? Also it helps to put print statements in spots when things aren't working.
Also I don't konw why you say local player = game.Players instead of local player = game.Players.LocalPlayer cause you can't access other clients from a local script anyways
The LocalScript is located in game.StarterGUI.VisibleStats.Frame.Stamina.LocalScript - There are 2 more frames after that, the 1st one is the border and the other one is the bar that's supposed to lower.