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

How would I make a gamepass to award the player with points?

Asked by 6 years ago

I have made a script that somebody helped me out with on this website, I edited it so it would give the person "Lifts" (basically money) and in studio it works but when I test the actual game it doesn't, help please?

01local Player = game.Players.LocalPlayer
02local passOwners = {} --add to this table if they buy it in game, so they don't have to rejoin
03game.Players.PlayerAdded:Connect(function(plr)
04    passOwners[plr.Name] = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 4643667)
05    plr.CharacterAdded:Connect(function(char)
06        if passOwners[plr.Name] then
07            Player:WaitForChild("leaderstats").Value = 1000000
08Player:WaitForChild("Lifts").Value = 1000000
09        end
10    end)
11end)

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

You're checking the gamepass from a LocalScript, which is not going to work I think. You must do this thing in a ServerScript. Here's the code

01local Player = game.Players.LocalPlayer
02local passOwners = {} --add to this table if they buy it in game, so they don't have to rejoin
03 
04game.Players.PlayerAdded:Connect(function(plr)
05    passOwners[plr.Name] = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 4643667)
06    plr.CharacterAdded:Connect(function(char)
07        if passOwners[plr.Name] then
08            Player:WaitForChild("leaderstats").Value = 1000000
09            Player:WaitForChild("Lifts").Value = 1000000
10        end
11    end)
12end)
0
If I understand it correctly, you also may want to have something like plr:WaitForChild("Lifts").Value = plr:WaitForChild("Lifts").Value = 1000000 so that if they already have some, they will get more of it. Creeperman1524 120 — 6y
0
but lifts is a value INSIDE of leaderstats... TheMaster9245 41 — 6y
0
Let me fix my code SulaymanArafat 230 — 6y
Ad

Answer this question