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

Help? My gamepass script isnt working and im trying to get it to give cash ingame.

I'm a beginner scripter, i'm using Zeds tycoon kit because I don't know how to make my own yet, this script is mine though as are many in my game, small simple ones as yet again I'm a beginner so help would be greatly appreciated. As stated above i'm using Zed's Tycoon kit and i'm trying to make a script to give people 10,000 cash when they join, i've been studying wiki.roblox but I just can't seem to make it work. Help would be greatly appreciated.

Script

id = 540679791
for i,v in pairs (game.Players:GetPlayers()) do
	if v then
		if game:GetService("MarketplaceService"):PlayerOwnsAsset(v,id) then
			local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(v.Name)
			if cashmoney then
				cashmoney.Value = cashmoney.Value + 10000
			end
		end
	end
end

Thanks for your time

--Species

1 comment

0

I recommend you trying to script or get some friends before making a game.

1 answer

✓ Accepted answer

Hello! So here's a solution to your problem:

You should use the game pass service instead of marketplace service, also you need to use :PlayerHasPass()

Here's an example, also your script fixed:

id = 540679791
for i,v in pairs (game.Players:GetPlayers()) do
    if v then
        if game:GetService("GamePassService"):PlayerHasPass(v,id) then
            local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(v.Name)
            if cashmoney then
                cashmoney.Value = cashmoney.Value + 10000
            end
        end
    end
end

The variables as you can see for :PlayerHasPass is (PLAYER,GAMEPASSID) Hope this worked!

3 comments

0

Have you seen his question? That's not what he is asking.

0

Thanks I just had to edit a few things like onPlayerEntered and such, I forgot about that. anyways, couldn't have done it without you!

0

No problem!

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