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

Tried to make a double XP/Gold Gamepass, but seem like it doesn't work, why?

Here's the script I have:

local gold = script.Parent.Config.Gold.Value
local exp = script.Parent.Config.XP.Value
local Humanoid = script.Parent.Humanoid
local id = 889632521
 
game.Players.PlayerAdded:connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) == true then 
	exp.Value = exp.value*2
	gold.Value = gold.value*2
end

function PwntX_X() 
local tag = Humanoid:findFirstChild("creator") 
	if tag ~= nil then 
		if tag.Value ~= nil then 
local Leaderstats = tag.Value:findFirstChild("leaderstats") 
			if Leaderstats ~= nil then 
Leaderstats.Gold.Value = Leaderstats.Gold.Value + gold
wait(0.1)
script:remove()
			end 
		end 
	end 
end 
Humanoid.Died:connect(PwntX_X) 



local Humanoid = script.Parent.Humanoid
function PwntX_X() 
local tag = Humanoid:findFirstChild("creator") 
	if tag ~= nil then 
		if tag.Value ~= nil then 
local Leaderstats = tag.Value:findFirstChild("leaderstats") 
			if Leaderstats ~= nil then 
Leaderstats.XP.Value = Leaderstats.XP.Value + exp
wait(0.1) 
script:remove()
			end 
		end 
	end 
end 
end)
Humanoid.Died:connect(PwntX_X) 

2 comments

1

Perhaps "PwntX_X" isn't the most informative function name...

1

Use MarketPlaceService instead, the gamepass service may be deprecated.

1 answer

Found your problem..

Your problem was that you had veribles of script.Parent.Config.Gold.Value

then 3 lines later you have gold.Value even though value was already stated, value is not a valid member of value.

I also made your code shorter.

local gold = script.Parent.Config.Gold
local exp = script.Parent.Config.XP
local Humanoid = script.Parent.Humanoid
local id = 889632521

game.Players.PlayerAdded:connect(function(player)
    if game:GetService("MarketplaceService"):PlayerHasPass(player, id) == true then 
     local newexp = exp.Value*2
     local newgold = gold.Value*2
end

function PwntX_X() 
local tag = Humanoid:findFirstChild("creator") 
    if tag ~= nil then 
        if tag.Value ~= nil then 
local Leaderstats = tag.Value:findFirstChild("leaderstats") 
            if Leaderstats ~= nil then
if game:GetService("MarketplaceService"):PlayerHasPass(player, id) == true then
Leaderstats.Gold.Value = Leaderstats.Gold.Value + newgold
Leaderstats.XP.Value = Leaderstats.XP.Value + newexp
else
Leaderstats.Gold.Value = Leaderstats.Gold.Value + gold.Value
Leaderstats.XP.Value = Leaderstats.XP.Value + exp.Value
end
wait(0.1)
script:remove()
            end 
        end 
    end 
end 
Humanoid.Died:connect(PwntX_X) 

If this helped make sure to check this answer as correct!

2 comments

0

No that didn't work. By the way, that Gold/XP.Value is for a IntValue inside of the Config.Gold/XP of how much the monster is dropping Gold/XP...

0

ok then.

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