Hello, I was making a script for a gui. The problem is the output says: 22:26:11.460 - Players.Player1.PlayerGui.BondsGui.Background.Paper.Enter.LocalScript:10: attempt to index local 'player' (a number value). How do I fix it?
local Contract = script.Parent.Parent.Parent.Parent
local CentralBank = game.Lighting.Bank
local InVal = script.Parent.Parent.InputVal.Value
local bondprice = game.Lighting.Bank.Price.BondPrice
function onClicked(player)
local OutVal = script.Parent.Parent.OutputVal.Value
local Money = player:WaitForChild("PlayerMoney")
local AccountName = Instance.new("StringValue")
AccountName.Parent = game.Lighting.Bank.BankAccounts
AccountName.Name = player.Name
local AccountType = Instance.new("StringValue")
AccountType.Parent = AccountName
AccountType.Name = "Bond"
local Worth = Instance.new("NumberValue")
Worth.Name = "Worth"
Worth.Value = OutVal
Worth.Parent = AccountName
CentralBank.BankMoney.Value = CentralBank.BankMoney.Value + OutVal
Money.Value = Money.Value - OutVal
Contract:Destroy()
wait()
end
script.Parent.MouseButton1Up:connect(onClicked)

1 comment
He defined the player in the argument of onClicked. Setting a variable won't do anything to help, the argument overwrites it anyways. He needs to remove the argument.