below is a script with zero errors:
players = game.Players:GetPlayers() while true do wait(1) print("test") for i,v in pairs(players) do print("test2") local character = v.Character or v.CharacterAdded:Wait() repeat wait() until character local humanoid = character:WaitForChild("Humanoid") if character:FindFirstChild("thirst").Value <= 20 then humanoid.Health = humanoid.Health - 40 end if character:FindFirstChild("hunger").Value <= 20 then humanoid.WalkSpeed = 5 else humanoid.WalkSpeed = 12 end tick() end end
no errors? then what is the problem? you may ask, I have no clue... where does it stop? it stops at the part where it says:
for i,v in pairs(players) do
it prints "test" but not "test2"
EDIT: i found out to fix it i had to put :getplayers into the while loop and make it local
Try:
local Players = game:GetService("Players") local function ThirstHunger(Player) while true do print("Test2") local Character = Player.Character or Player.CharacterAdded:Wait() local Humanoid = Character:WaitForChild("Humanoid") if Character.thirst.Value <= 20 then Humanoid.Health = Humanoid.Health - 40 end if Character.hunger.Value <= 20 then Humanoid.WalkSpeed = 5 else Humanoid.WalkSpeed = 12 end wait(1) end end Players.PlayerAdded:Connect(ThirstHunger)