this is the error Infinite yield possible on 'Players.Player1:WaitForChild("Character")'
here's a part of the script
game.Players.LocalPlayer:WaitForChild("leaderstats") game.Players.LocalPlayer.leaderstats:WaitForChild("Level") game.StarterGui:WaitForChild("Hp") game.StarterGui.Hp.Frame.Frame:WaitForChild("HpPart") game.StarterGui.Hp.Lv:WaitForChild("LVL DISPLAY SCRIPT")
local player = game.Players.LocalPlayer player:WaitForChild("Character") local Character = player.Character
if game.Players.LocalPlayer.leaderstats.Level.Value == 1 then player.Character.Humanoid.MaxHealth = 250 player.Character.Humanoid.Health = 250 end
the problem is in this part
local player = game.Players.LocalPlayer player:WaitForChild("Character") local Character = player.Character
i can't figure it out? any help ?
Essentially all this means is that ROBLOX is warning you that your script can potentially wait forever, if the object you set to wait for hasn't been made.
You shouldn't have a problem with it (and it is just a warning, not an error), but if you want to get rid of the error, set a time where if the object is not created, the WaitForChild will just return nil and end. Ex:
game.Workspace:WaitForChild("Part", 100) -- if after 100 seconds there is no part in the workspace, this function will return nil.
In your following script,
local player = game.Players.LocalPlayer player:WaitForChild("Character") local Character = player.Character
Remove the part
player:WaitForChild("Character")
The correct script becomes
local player = game.Players.LocalPlayer
local Character = player.Character
Character is not child of player although we can write player.Character.
player:WaitForChild("Character") will always result infinite yield since player will never get a child named Character.
if you want to make sure player.Character exists, use
local Character = player.Character or player.CharacterAdded:wait()