Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

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

1 answer

✓ Accepted answer

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

local Player = game.Players.LocalPlayer
local passOwners = {} --add to this table if they buy it in game, so they don't have to rejoin

game.Players.PlayerAdded:Connect(function(plr)
	passOwners[plr.Name] = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 4643667)
	plr.CharacterAdded:Connect(function(char)
        if passOwners[plr.Name] then
			Player:WaitForChild("leaderstats").Value = 1000000
			Player:WaitForChild("Lifts").Value = 1000000
		end
	end)
end)

3 comments

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.

0

but lifts is a value INSIDE of leaderstats...

0

Let me fix my code

This discussion is preserved as it was. New answers, comments, and votes are closed.