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

Value is not a valid member or Tool | Banknote | [Jojo Games] ?

Hello, I am coming again to ask for help from your community since I am stuck on something easy, yet I cannot find the solution.

I created a script that allows you to add money when you click, however nothing happens, I have this error when I click.

12:25:59.515 - Value is not a valid member of Tool 12:25:59.516 - Stack Begin 12:25:59.517 - Script 'Workspace.maxime66410.Banknote.LocalScript', Line 9 12:25:59.517 - Stack End

So I'm totally stuck, I can show you the script (not finished).

BankNote Script (LocalScript or Script also does not work) :

local Money = script.Parent



Money.Equipped:Connect(function(Mouse)
	Mouse.Button1Down:connect(function()
			
				local tag = game:GetService("Players").LocalPlayer:FindFirstChild("Money").Value
				local player = game.Players:FindFirstChild(Money.Value)
				local amount = math.random(150,10000)
				player = player + amount
			
		
	end)	
end)

First Version of my script :

local Money = script.Parent
local tag = script.Parent.Tag



Money.Equipped:Connect(function(Mouse)
	Mouse.Button1Down:connect(function()
		if tag.Value ~= nil then
			if game.Players:FindFirstChild(tag.Value) then
					local player = game.Players:FindFirstChild(Money.Value)
					local amount = math.random(150,10000)
					player = player + amount
			end
		end	
	end)	
end)

And Version final of my scripts but i don't have error, but still no money to add.

local Money = script.Parent
local tag = game:GetService("Players").LocalPlayer
local addMoney = game:GetService("ReplicatedStorage").Logic.AddMoney



Money.Equipped:Connect(function(Mouse)
	Mouse.Button1Down:connect(function()
		if tag ~= nil then
			if game.Players:FindFirstChild(tag) then
				local player = game.Players:FindFirstChild(tag)
				local amount = math.random(150,10000)
				player:FindFirstChild("Money").Value = player:FindFirstChild("Money").Value + amount
				addMoney:FireServer(player,tag)
			end
		end	
	end)	
end)

2 comments

0

What is Money? A stringvalue?

0

Tag = StringValue | Money = NumberValue

1 answer

✓ Accepted answer

In your last version of the script. You wrote at line 2:

"local tag = game:GetService("Players").LocalPlayer"

Which isn't a string. Instead write this:

"local tag = game:GetService("Players").LocalPlayer.Name"

local Money = script.Parent
local tag = game:GetService("Players").LocalPlayer.Name
local addMoney = game:GetService("ReplicatedStorage").Logic.AddMoney



Money.Equipped:Connect(function(Mouse)
    Mouse.Button1Down:connect(function()
        if tag ~= nil then
            if game.Players:FindFirstChild(tag) then
                local player = game.Players:FindFirstChild(tag)
                local amount = math.random(150,10000)
                player:FindFirstChild("Money").Value = player:FindFirstChild("Money").Value + amount
                addMoney:FireServer(player,tag)
            end
        end 
    end)    
end)

4 comments

0

it works thanks, Now I have to make sure that the data is back up.

0

Oh no, rectification it does not work, 14:51:58.056 - Workspace.Banknote.Script:2: attempt to index nil with 'Name' 14:51:58.056 - Stack Begin 14:51:58.057 - Script 'Workspace.Banknote.Script', Line 2 14:51:58.057 - Stack End

0

Maxime, it does work. You just cannot get the localplayer from a normal script, it must be a localscript (cant be in the workspace either)

0

Yes I understand, that was a bit of a stupid question, well at least I now have to make sure that it save.

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