Hello, I am making a sim game (taco sim) and I am trying to make it so when you prestige it increases the amount of tacos you get and for some reason it doesn't make the PrestigeExtra.Value 1. Can someone help me? (Ik that this script is messy lul)

local datastore = game:GetService("DataStoreService")
local data1 = datastore:GetDataStore("mytacodata")
local data2 = datastore:GetDataStore("myprestigedata1")
local data3 = datastore:GetDataStore("PrestigePercent")


game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"

local prestige = Instance.new("IntValue", leaderstats)
prestige.Name = "prestige"

local tacos = Instance.new("IntValue", leaderstats)
tacos.Name = "tacos"

local prestigestats = Instance.new("Folder",player)
prestigestats.Name = "PrestigeStats"

local PrestigeExtra = Instance.new("IntValue",prestigestats)
PrestigeExtra.Name = "PrestigeData"
PrestigeExtra.Value = 1

tacos.Value = data1:GetAsync(player.UserId) or 0
data1:SetAsync(player.UserId, tacos.Value)

prestige.Value = data2:GetAsync(player.UserId) or 0
data2:SetAsync(player.UserId, prestige.Value)

PrestigeExtra.Value = data3:GetAsync(player.UserId) or 0 -- is this wrong?!?!?
data3:SetAsync(player.UserId, PrestigeExtra.Value)



game.Players.PlayerRemoving:connect(function()
     data1:SetAsync(player.UserId, tacos.Value)
     data2:SetAsync(player.UserId, prestige.Value)
     data3:SetAsync(player.UserId, PrestigeExtra.Value)
     end)
end)

The script that gives tacos is here:

game.ReplicatedStorage.TacoEvent.OnServerEvent:connect(function(player)
	local prestige = player.PrestigeStats.PrestigeData
	player.leaderstats.tacos.Value = player.leaderstats.tacos.Value + 2 * prestige.Value 
end)

2 comments

0

It's because you're saying "or 0" you should say "or" then the number you want

0

@iiDev_Potato that 'or 0' is for the default value when there is nothing in the data stores for the specific player (first time they joined the game). For the script itself, I don't see you firing anything to the server.