Attempt to index nil with 'Changed'

Hello! Im making a stamina system and this local script listens to whenever the value of the stamina IntValue changes. I don’t know why this is happening as everything is spelt right and is in the right place. If you could help me, I would really appreciate it.

Thank you.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local stamina = char:FindFirstChild("Stamina")
local maxstamina = 100
local ts = game:GetService("TweenService")
local ti =, Enum.EasingStyle.Quint, Enum.EasingDirection.In)

	local percent = plr.Character:FindFirstChild("Stamina").Value / maxstamina * 0.35
	ts:Create(script.Parent, ti, {Size =, 0, 0.064, 0)})
	--script.Parent.Size =, 0, 0.064, 0)
	--the 0.064 value is the Y value of GreenBar

probably because the script runs before the Stamina value gets created, try replacing the FindFirstChild in the stamina variable with WaitForChild

1 Like

thanks :sweat_smile: i cant believe i didnt think of that

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.