Hello!
I’m having a issue where it won’t print even though I have what is needed. (Code below). There are no errors, etc. Thanks!
local ds1 = datastore:GetDataStore("CashSaveSystem")
local ds2 = datastore:GetDataStore("CustomersSaveSystem")
game.Players.PlayerAdded:Connect(function(player)
if player then
local folder = Instance.new("Folder")
folder.Name = "leaderstats"
folder.Parent = player
local Customers = Instance.new("IntValue")
Customers.Parent = folder
Customers.Name = "Customers"
local Cash = Instance.new("IntValue")
Cash.Parent = folder
Cash.Name = "Cash"
Cash.Value = ds1:GetAsync(player.UserId) or 0
ds1:SetAsync(player.UserId, Cash.Value)
Cash.Changed:Connect(function()
ds1:SetAsync(player.UserId, Cash.Value)
end)
Customers.Value = ds2:GetAsync(player.UserId) or 0
ds2:SetAsync(player.UserId, Customers.Value)
Customers.Changed:Connect(function()
ds2:SetAsync(player.UserId, Customers.Value)
end)
end
end)
game.Players.PlayerAdded:Connect(function(player)
player:WaitForChild("leaderstats")
if player.leaderstats.Customers.Value == 7 then
print("test")
end
end)
1 Like
This might be the one that paused the script?
Winbloo
(Winbloo)
June 23, 2021, 12:36pm
#3
How much customers exactly does your player? I’m assuming you meant to use “bigger than” instead of “equal to” for the operator.
This checks if the player has exactly 7 customers, use “>” instead if you want to compare if .Value is bigger than 7.
Nope. Removing that makes it throw this error:
The player I have has exactly 7, I’m using the exact way just as a testing feature.
can you just do like
if player:WaitForChild("leaderstats").Customers.Value == 7 then
instead?
You could, but nothing changes.
I have an idea about what’s happening
the value will be changed, right?
it wont detect the value if changed
do like
player:WaitForChild("leaderstats").Customer:GetPropertyChangedSignal("Value"):Connect(function()
player:WaitForChild("leaderstats")
if player.leaderstats.Customers.Value == 7 then
print("test")
end
end)
so that it will detects if the value has changed
1 Like
Winbloo
(Winbloo)
June 23, 2021, 12:48pm
#10
I’m not really sure if this is the problem, but maybe both of the functions are running at the same time… Try using .CharacterAdded for:
Or can’t you just include the second function inside the first?
Customers.Value = ds2:GetAsync(player.UserId) or 0
ds2:SetAsync(player.UserId, Customers.Value)
if ds2(Player.UserId, Customers.Value) == 7 then
print("hi")
end