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

Money is not a valid member of Folder?

Someone Please Explain What Is Wrong? Attached Below Is The Script.


Tool = script.Parent

Tool.Activated:Connect(function()
	local chr = script.Parent.Parent
	local player = game.Players:GetPlayerFromCharacter(chr)
	local data = player:WaitForChild("Data")
	local money = data.Money
	
	print(player.Name.."used a Banknote.")
	money.Value = money.Value + 500
	
	Tool:Destroy()
end)


2 comments

1

If money is not a valid member of folder that means the IntValue for Money doesn't exist in Data i.e the problem lies in another script, why isn't money in the data folder?

0

your money probably dont have a intvalue

1 answer

If you do not already have a script for the Money then here it is:

local function playerAdded(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"

	local money = Instance.new("IntValue")
	money.Parent = leaderstats
	money.Name = "Money"
	
	leaderstats.Parent = player
end

game.Players.PlayerAdded:Connect(playerAdded)

Then this will be your script:

Tool = script.Parent

Tool.Activated:Connect(function()
    local chr = script.Parent.Parent
    local player = game.Players:GetPlayerFromCharacter(chr)
    local data = player:WaitForChild("leaderstats")
    local money = data.Money

    print(player.Name.."used a Banknote.")
    money.Value = money.Value + 500

    Tool:Destroy()
end)

Might work...

1 comment

0

will also not work, changes will be local

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