game.Players.PlayerAdded:Connect(function(player)
local leaderstatsP = player:WaitForChild("leaderstatsP")
local Sky = leaderstatsP:WaitForChild("Sky")
if Sky.Value == 1 then
player.PlayerGui.SkyScript.Disabled = false
wait(10)
player.PlayerGui.SkyScript.Disabled = true
end
end)
and this what i got on output
Infinite yield possible on ‘Players.MONSTERGAMES3609.leaderstatsP:WaitForChild(“Sky”)’
Alright, so basically I’m not sure if this will work or not. But I want you to try 2 things.
1st thing:
--Change the the variables Sky and leaderstats to:
local leaderstatsP = player:WaitForChild("leaderstatsP", 5)
local Sky = leaderstatsP:WaitForChild("Sky", 5)
If this doesn’t work then try:
local leaderstatsP = player:FindForChild("leaderstatsP", true)
local Sky = leaderstatsP:FindForChild("Sky", true)
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("PetsStats") -- Change this with a different name.
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("SkyStats") -- Change this with a different name.
game.Players.PlayerAdded:Connect(function(Player)
local LeaderstatsP = Instance.new("Folder", Player)
LeaderstatsP.Name = "leaderstatsP"
local completed = Instance.new('Folder')
completed.Name = 'completed'
completed.Parent = Player
local Pets = Instance.new("IntValue", Player.leaderstatsP)
Pets.Name = "Pets" -- Change "Kills" with your currency.
Pets.Value = 0 or DataStore
local Data = DataStore:GetAsync(Player.UserId)
local Sky = Instance.new("IntValue", Player.leaderstatsP)
Sky.Name = "Sky" -- Change "Kills" with your currency.
Sky.Value = 0 or DataStore
local Data = DataStore:GetAsync(Player.UserId)
local FirePet = Instance.new("IntValue", Player.leaderstatsP)
FirePet.Name = "FirePet" -- Change "Kills" with your currency.
FirePet.Value = 0
if Data then
Pets.Value = Data.Pets -- Change "Kills" with your currency.
Sky.Value = Data.Sky -- Change "Kills" with your currency.
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
DataStore:SetAsync(Player.UserId, {
["Pets"] = Player.leaderstatsP.Pets.Value; -- Change "Kills" with your currency.
["Sky"] = Player.leaderstatsP.Sky.Value; -- Change "Kills" with your currency.
})
end)
I noticed that leaderstatsP is waitforchild, yet when you call it later it it could be the child or the variable. I am not totally sure about this, but it could be an issue. Try making the local leadP instead.
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("PetsStats") -- Change this with a different name.
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("SkyStats") -- Change this with a different name.
game.Players.PlayerAdded:Connect(function(Player)
local LeaderstatsP = Instance.new("Folder", Player)
LeaderstatsP.Name = "leaderstatsP"
local completed = Instance.new('Folder')
completed.Name = 'completed'
completed.Parent = Player
local Pets = Instance.new("IntValue", Player.leaderstatsP)
Pets.Name = "Pets" -- Change "Kills" with your currency.
Pets.Value = 0 or DataStore
local Data = DataStore:GetAsync(Player.UserId)
local Sky = Instance.new("IntValue", Player.leaderstatsP)
Sky.Name = "Sky" -- Change "Kills" with your currency.
Sky.Value = 0 or DataStore
if Sky.Value == 1 then
player.PlayerGui.SkyScript.Disabled = false
wait(10)
player.PlayerGui.SkyScript.Disabled = true
end
local Data = DataStore:GetAsync(Player.UserId)
local FirePet = Instance.new("IntValue", Player.leaderstatsP)
FirePet.Name = "FirePet" -- Change "Kills" with your currency.
FirePet.Value = 0
if Data then
Pets.Value = Data.Pets -- Change "Kills" with your currency.
Sky.Value = Data.Sky -- Change "Kills" with your currency.
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
DataStore:SetAsync(Player.UserId, {
["Pets"] = Player.leaderstatsP.Pets.Value; -- Change "Kills" with your currency.
["Sky"] = Player.leaderstatsP.Sky.Value; -- Change "Kills" with your currency.
})
end)