I have been trying to use this code in my game to award player points if someone does not die for 5 seconds, but it wont work.
-- declare service local PointsService = Game:GetService("PointsService") -- Bind function to player added event game.Players.PlayerAdded:connect(function(player) -- Get total number of points this game has already awarded to the player local universeBalance = PointsService:GetGamePointBalance(player.userId) -- Check if the player has died. If true, don't award points for 10 seconds. If false, award points every 5 seconds while true do game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) if character:WaitForChild("Humanoid").Died:connect(function() end) then wait(10) else wait(5) PointsService:AwardPoints(player.userId, 1) end end) -- Bind function to when points are successfully awarded PointsService.PointsAwarded:connect(function(userId, userBalanceinUni, userBalance) end)
I would love it if your could help. Thanks!
This script does not make much sense. You should not have more than one PlayerAdded function. And if character:WaitForChild("Humanoid").Died:connect(function() end)
will always evaluate true, because it returns a connection object. I'm not quite sure what you wanted it to do, but you are better off checking humanoid health.
local PointsService = game:GetService("PointsService") game.Players.PlayerAdded:connect(function(player) --set variables local id = player.UserId local universeBalance = PointsService:GetGamePointBalance(id) local char = player.Character or player.CharacterAdded:wait() local humanoid = char:WaitForChild('Humanoid') player.CharacterAdded:connect(function(character) --reset the variables char, humanoid = character, character:WaitForChild('Humanoid') end) --simple loop while wait(5) do if humanoid.Health > 0 then PointsService:AwardPoints(id, 1) else wait(5) end end end)