Hi.
How can I check every single player's leaderstats.reputation.Value every 4 seconds?
--do this to every player: if(Player:FindFirstChild("leaderstats")) then if(Player.leaderstats.reputation.Value < 0)then --do things end end wait(4) --repeat
Uh, one more thing. There is this function, getPlayerFromCharacter(). I'm looking for a function that would do the opposite thing.
while wait(4) do for _, Player in pairs(game.Players:GetPlayers()) do --do this to every player: if Player:FindFirstChild("leaderstats") then if Player.leaderstats.reputation.Value < 0 then --do things end end end --repeat end
As for your question involving getting the character from the Player, the character is a child of the Player, so you can index it the way you'd index any child.Player.Character
Hope this helps you
Use Events instead. I am highly against using polling-based solutions where Roblox provides an event-based alternative. Use Value.Changed
instead.
Reputation.Changed:connect(function(newRep) if newRep < 0 then -- Do things. end end)
If you need the Player, you'll want to stick that inside of a PlayerAdded just as DepressionSensei's answer suggests.