I've got a "cash exchange system" you type in the amount of cash that you want to give to someone, then press a button. It puts a bag in your inventory with the amount of money that you put in the text box. The only problem is that I cant get the amount of money that is suppose to be put in the bag with filtering enabled on. I get the error : attempt to index a nil value. When I try to get the amount in a server script. Here is the code:
Local script (in gui):
local Player = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() local text = script.Parent.Parent.AmountBox local Amount = tonumber(text.Text) if Player.Stats.Beli.Value >= Amount and Amount ~= 0 and Amount > -1 then script.Parent.Parent.Parent.Parent.UI_Click:Play() Player.Backpack.BeliClicked:FireServer() elseif Player.Stats.Beli.Value < Amount or Amount ~= 0 or Amount > -1 then script.Parent.Parent.Parent.Parent.UI_Error:Play() end end)
Server sided script(in backpack):
script.Parent.BeliClicked.OnServerEvent:Connect(function(Player) local text = Player.PlayerGui:FindFirstChild("Main"):FindFirstChild("DropBeli"):FindFirstChild("AmountBox") --error comes from here local Amount = tonumber(text.Text) script.value.Value = Amount if Player.Stats.Beli.Value >= script.value.Value then Player.Stats.Beli.Value = Player.Stats.Beli.Value - script.value.Value local bag = game.ReplicatedStorage.Items.MoneyBag:Clone() bag.Handle.Amount.Value = script.value.Value bag.Parent = Player.Backpack bag.ToolTip = (script.value.Value) end end)