Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make script for giving leaderstats Cash if have gamepass?

Asked by 5 years ago
Edited 5 years ago

I used to have an old one that works but after the game pass update it broke?

Any help? Please and thank you!

What I mean: You have a game pass, the script checks if you have that game pass, if so gives you Cash from the leader stats.

This is my leaderboard script


local datastore = game:GetService("DataStoreService") local data1 = datastore:GetDataStore("mycashdata") local data2 = datastore:GetDataStore("myrebirthsdata") local data3 = datastore:GetDataStore("myKillssdata") game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Folder",player) leaderstats.Name = "leaderstats" local rebirths = Instance.new("IntValue", leaderstats) rebirths.Name = "Cash" local strength = Instance.new("IntValue", leaderstats) strength.Name = "Kills" strength.Value = data1:GetAsync(player.UserId) or 0 data1:SetAsync(player.UserId, strength.Value) rebirths.Value = data2:GetAsync(player.UserId) or 0 data2:SetAsync(player.UserId, rebirths.Value) game.Players.PlayerRemoving:connect(function() data1:SetAsync(player.UserId, strength.Value) data2:SetAsync(player.UserId, rebirths.Value) end) end)
0
Holy crap indent your code User#24403 69 — 5y
0
Please indent | use Connect not connect | Do not use the 2nd arguement of Instance.new | use pcalls for data saving and reading | use better datastore names and variable names green271 635 — 5y
0
Then you post an answer Ziffixture 6913 — 5y

Answer this question