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

Whats wrong with this script?

Well,I tried to edit it up but It still wont work. any reason why?

local gps = game:GetService("GamePassService")
local players = game:GetService("Players")

local passId = script:WaitForChild("GamePassID")

function registerPlayer(plr)
	if gps:PlayerHasPass(plr, passId) then
		local cashmoney = game.ServerStorage.MoneyStorage:WaitForChild(player.Name)
			cashmoney.Value = cashmoney.Value + 5000
	end
end

players.PlayerAdded:connect(registerPlayer)

1 answer

✓ Accepted answer

That's an often made mistake. I'll explain it with comments.

local gps = game:GetService("GamePassService")
local players = game:GetService("Players")

local passId = script:WaitForChild("GamePassID")

function registerPlayer(plr)
    if gps:PlayerHasPass(plr, passId.Value) then -- passId most likely is an Integer or Numerical Value, thus you need to add .Value as it is the property of that Value.
        local cashmoney = game.ServerStorage.MoneyStorage:WaitForChild(player.Name)
            cashmoney.Value = cashmoney.Value + 5000
    end
end

players.PlayerAdded:connect(registerPlayer)

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