Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited 3 years ago

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)
0
What is Money? A stringvalue? rabbi99 714 — 3y
0
Tag = StringValue | Money = NumberValue Maxime66410 14 — 3y

1 answer

Log in to vote
0
Answered by
rabbi99 714 Moderation Voter
3 years ago

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)
0
it works thanks, Now I have to make sure that the data is back up. Maxime66410 14 — 3y
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 Maxime66410 14 — 3y
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) Pupppy44 671 — 3y
0
Yes I understand, that was a bit of a stupid question, well at least I now have to make sure that it save. Maxime66410 14 — 3y
Ad

Answer this question