donateButton.MouseButton1Down:connect(function(donate)
	if game.Players:FindFirstChild(playerName.Text) then
		local donatePlayer = playerName.Text
		if tonumber(donateAmount.Text) ~= nil then
			if player.leaderstats.Cash.Value >= tonumber(donateAmount.Text) then
				player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - donateAmount.Text
				print(donatePlayer)
				donatePlayer:WaitForChild("leaderstats"):WaitForChild("Cash").Value = donatePlayer.leaderstats.Cash.Value + donateAmount -- ERROR HERE
			end
		end
	end
end)

Player2 11:17:10.187 - Players.Player1.PlayerGui.HUD.DonateFrame.DonateScript:32: attempt to call method 'WaitForChild' (a nil value) 11:17:10.188 - Stack Begin 11:17:10.188 - Script 'Players.Player1.PlayerGui.HUD.DonateFrame.DonateScript', Line 32 11:17:10.189 - Stack End Output says that WaitForChild on a nil value. I have a print(donatePlayer) which prints Player2 but it dosent do the next line saying it cannot WaitForChild as it is apparently a nil value. Anyone got any ideas?

  • NinjoOnline

2 comments

0

Do you have another script that is putting in the Cash value, if so is that value named "Cash". Also, why are you using WaitForChild() on an object that you have accessed before?

0

I dont think that's what's erroring. I think that when you set the value on line 6 then it errors since you're not using WaitForChild / FindFirstChild.