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)
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)