whenever i test this gamepass is tells me attempt to index nil with a value.like this worked for other things why doesent it work on this.
local id = 10391218 local stats = game.ServerScriptService:WaitForChild("LeaderStats"):FindFirstChild("leaderstats") local Pmoney = game.ServerScriptService:WaitForChild("LeaderStats"):FindFirstChild("Cash") local Pmulti = game.ServerScriptService:WaitForChild("LeaderStats"):FindFirstChild("Multi") local Preb = game.ServerScriptService:WaitForChild("LeaderStats"):FindFirstChild("Rebirths") game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) if purchased and id == ido then Pmulti.Value = Pmulti.Value + 1000000 --problem end end)
sorry if this is very messy i tried to make it simple but it didn't work or maybe it did.
Maybe use ("LeaderStats"):WaitForChild(variableName) so it will yield until the object is loaded. If this doesn't work then please click on the error message in the output and tell us which line the error is from.
You're trying to get leaderstats
through ServerScriptService
. That's not how you do it.
leaderstats
goes inside every player that joins in a game. So you would want to try something like this:
local leaderstats = player:WaitForChild("leaderstats") local Pmulti = leaderstats:FindFirstChild("Multi") Pmulti.Value = Pmulti.Value + 5 --Just a little test
I'm not sure as to how you're getting the player in this server script so I didn't include how I got a player. Hope this makes you understand a little more about leaderstats.