Is this local Script or a regular script? And where is this placed?
It’s a script and its on ServerScriptService
How do you firstly create that value? I tried this my own and worked, here I leave the script I made:
game.Players.PlayerAdded:Connect(function(player)
local LeaderstatsP = Instance.new("Folder")
LeaderstatsP.Name = "leaderstatsP"
LeaderstatsP.Parent = player
local SkyNew = Instance.new("StringValue")
SkyNew.Name = "Sky"
SkyNew.Parent = LeaderstatsP
local leaderstatsP = player:WaitForChild("leaderstatsP")
local Sky = leaderstatsP:WaitForChild("Sky")
print(Sky.Parent)
if Sky.Value == 1 then
player.PlayerGui.SkyScript.Disabled = false
wait(10)
player.PlayerGui.SkyScript.Disabled = true
end
end)
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)
Let me know if this helped!
there is no issues in the leaderstatsP
they are two don’t work
but in first one no output massges
Can you show me the script where you made the leaderstatsP
Add game.wait() at the beginning of the script
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.
Did you add an event in replicated storage named “Sky”
no but there is a sky named sky
The error is happens before anything is done to sky, the error is when calling sky.
This article should explain some stuff wrong with your script:
i think the problem in local leaderstatsP and local Sky
Try doing everything in a single script:
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)
don’t work
idk why …
I made some changes and its work
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
game.StarterGui.SkyScript.Disabled = false
wait(10)
game.StarterGui.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)
tysm bro tysm .