game.ReplicatedStorage.GiveMoney.OnServerEvent:Connect(function()
game:GetService("Players"):FindFirstChild(script.Parent.Parent.StarterGui.ControlPlayersGUI.CurrencyController.CashGiver.PlayerName.Text):FindFirstChild("leaderstats"):FindFirstChild("Cash").Value = game:GetService("Players"):FindFirstChild(script.Parent.Parent.StarterGui.ControlPlayersGUI.CurrencyController.CashGiver.PlayerName.Text):FindFirstChild("leaderstats"):FindFirstChild("Cash").Value - tonumber(script.Parent.Parent.StarterGui.ControlPlayersGUI.CurrencyController.CashGiver.Amount.Text) -- The error line
end)
COMMUNITY QUESTION
attempt to index nil with 'FindFirstChild'?
1 answer
Server-Sided script: (Fixed!)
-- Cash
script.Parent.GiveCash.OnServerEvent:Connect(function(o, player, amt)
game.Players[player].leaderstats.Cash.Value = game.Players[player].leaderstats.Cash.Value + amt
end)
script.Parent.RemoveCash.OnServerEvent:Connect(function(o, player, amt)
game.Players[player].leaderstats.Cash.Value = game.Players[player].leaderstats.Cash.Value - amt
end)
-- Rebirths
script.Parent.GiveRebirths.OnServerEvent:Connect(function(o, player, amt)
game.Players[player].leaderstats.Rebirths.Value = game.Players[player].leaderstats.Rebirths.Value + amt
end)
script.Parent.RemoveRebirths.OnServerEvent:Connect(function(o, player, amt)
game.Players[player].leaderstats.Rebirths.Value = game.Players[player].leaderstats.Rebirths.Value - amt
end)
Here is the local script for giving cash: (Fixed!)
script.Parent.MouseButton1Click:Connect(function()
local player = script.Parent.Parent.PlayerName.Text
local cash = script.Parent.Parent.Amount.Text
script.Parent.Parent.Parent.GiveCash:FireServer(player,cash)
end)
2 comments
0
Try putting a 'wait(1)' above all the code.
0
THANK YOU!!!!
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
You are using GetService. Try just using game.Players
It gives me another error, because GetService is a requirement when referring to a player