Anyways, what I am trying to make is a script that if they have the specific game pass, they can have infinite stamina, but the stamina value is located in the backpack, under a local script named globalfunctions. The problem is that for some reason it cant seem to find "Backpack".
local passId = 318909278 function isAuthenticated(player) return game:GetService("GamePassService"):PlayerHasPass(player, passId) end game.Players.PlayerAdded:connect(function(plr) if isAuthenticated(plr) then repeat wait() until plr.Backpack.GlobalFunctions.Stamina spawn(function() while wait() do plr.Backpack.GlobalFunctions.Stamina.Value = 100 end end) end end)
Anyways, output says this: http://prntscr.com/91oxpt
Well yeah, the code can't find the backpack. If I had to guess, I think the code checks for the backpack way too early, that the backpack wasn't loaded yet.
All I did was added a wait on finding the backpack:
local passId = 318909278 function isAuthenticated(player) return game:GetService("GamePassService"):PlayerHasPass(player, passId) end game.Players.PlayerAdded:connect(function(plr) if isAuthenticated(plr) then repeat wait() until plr:WaitForChild('Backpack').GlobalFunctions.Stamina spawn(function() while wait() do plr.Backpack.GlobalFunctions.Stamina.Value = 100 end end) end end)