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

My ROBLOX Script Broke On My Game With $ Stuff While It Works Without Some Parts. Can Someone Help?

Help! My Script Is Broken! It Won't Do Anything To The Money. Can Someone Fix It? It Worked Without The (If PlayerHasPass (code) then) Part But I need that part. Thanks!

game.Players.PlayerAdded:connect(function(p)
local stats = Instance.new("IntValue", p)
stats.Name = "leaderstats"
local money = Instance.new("IntValue", stats)
money.Name = "Experience"
money.Value = 50000
while true do
wait(1)
money.Value = money.Value + 1
if PlayerHasPass (1446105009) then
	wait (1)
	money.Value = money.Value + 9
end
end
end)

Gamepass Code: 1446105009

1 comment

0

To shorten your title, you do NOT need to say "my roblox script broke on my game" because why else would you be here?

2 answers

PlayerHasPass needs to be:

if game:GetService("GamePassService"):PlayerHasPass(p, 1446105009) then 

2 comments

0

If it works please press the accept answer button

0

no, GamePassService is deprecated

Add this to the beginning of your code:

local PlayerHasPass = function(player, pass)
	if pcall(game.isA, player, "Player") then
		return game.MarketplaceService:PayerOwnsAsset(player, pass)
	else
		error("Get no player for argument 1")
	end
end

Now, we can call it like:

if PlayerHasPass(p, 1446105009) then
	print(p, "has gamepass", 1446105009, "!")
end

1 comment

0

On Line 3 of the PlayerHasPass function, I found something. You spelled PlayerOwnsAsset wrong.

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