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

Why won't this gamepass script give money?

I'm using Berezaas tycoon kit, and it stores the money inside of

ServerStorage V MoneyStorage V Player (numvalue) and then the Value property in Player

Here's the code (yes the gamepass id is defined, its just in the script earlier)

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function()
local swag = game.ServerStorage.MoneyStorage:FindFirstChild("player.Name")		
if game:GetService("GamePassService"):PlayerHasPass(player.userId, id) then
swag.Value = swag.Value + 2500
end end) end)

1 answer

You are searching ServerStorage for something named "Player.Name" and not the players name. Also there is no reason to use FindFirstChild if you are not going to check if the object exists.

Also note that you are giving the player money every time he respawns. Which could be abused.

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function()
		local swag = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)      
		if game:GetService("GamePassService"):PlayerHasPass(player.userId, id) and swag then
			swag.Value = swag.Value + 2500
		end 
	end)
end)

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