local DataStoreService = game:GetService("DataStoreService") local tapsStore = DataStoreService:GetDataStore("Taps") local starterGui = game:GetService("StarterGui") local replicatedStorage = game:GetService("ReplicatedStorage") local UpdateRebirthGui = replicatedStorage.UpdateRebirthGui local event = Instance.new("RemoteEvent") event.Name = "AddStats" event.Parent = game.ReplicatedStorage event.OnServerEvent:Connect(function(plr) local taps = plr.leaderstats.Taps taps.Value = taps.Value +1 end) game.Players.PlayerAdded:Connect(function(plr) --create leaderstats local is = Instance.new("Folder") is.Name = "leaderstats" is.Parent = plr local menu = Instance.new ("IntValue", is) menu.Name = "Taps" local taps = tapsStore:GetAsync("Player_"..plr.UserId) local success, errormessage = pcall (function() starterGui.TapGui.Frame.counter.Text = taps end) if success then menu.Value = taps else warn(errormessage) end end)
The error is between line 13-15
You need to make the leaderstats FIRST before using the remote event. Programming languages moves from one line to the next. If the remote event tries to find leaderstats, it will result in nil
because leaderstats do not exist yet. So you have to make the leaderstats first before doing the remote event.
game.Players.PlayerAdded:Connect(function(plr) --ALWAYS make leaderstats top priority. --create leaderstats local is = Instance.new("Folder") is.Name = "leaderstats" is.Parent = plr local menu = Instance.new("IntValue", is) menu.Name = "Taps" local taps = tapsStore:GetAsync("Player_"..plr.UserId) local success, errormessage = pcall(function() starterGui.TapGui.Frame.counter.Text = taps end) if success then menu.Value = taps else warn(errormessage) end end) local event = Instance.new("RemoteEvent") event.Name = "AddStats" event.Parent = game.ReplicatedStorage event.OnServerEvent:Connect(function(plr) local taps = plr.leaderstats.Taps taps.Value = taps.Value +1 end)
Yeah when your getting something from below the line your on the script won't recognize it cuz it hasn't gotten there yet.