[Solved by me] My else if statment stops working in a specific area for some reason

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to make tags for donators who donated my game
  2. What is the issue? Include screenshots / videos if possible!
    My “If then elseif” script won’t work for some reason
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried debugging buy using prints but I haven’t gotten anywhere

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

	if receiptInfo.ProductId == 1173330375 then --5 robux
				local DonoStats = game.Players:GetPlayerByUserId(receiptInfo.PlayerId):WaitForChild("leaderstats").Donation
				game:GetService("BadgeService"):AwardBadge(receiptInfo.PlayerId, 2126648445)
				DonoStats.Value = game.Players:GetPlayerByUserId(receiptInfo.PlayerId):WaitForChild("leaderstats").Donation.Value + 5
				wait()
				if game.Players:GetPlayerByUserId(receiptInfo.PlayerId).leaderstats.Donation.Value > 0 and game.Players:GetPlayerByUserId(receiptInfo.PlayerId).leaderstats.Donation.Value < 10000 and not game.Players:GetPlayerByUserId(receiptInfo.PlayerId).Character.Head:FindFirstChild("Donator") then
					local char = game.Players:GetPlayerByUserId(receiptInfo.PlayerId).Character
					local Storage = game:GetService("ReplicatedStorage").nameTags
					local Gui = Storage.Donator:Clone()
					Gui.Parent = char.Head
					Gui.Adornee = char.Head
				elseif -- the script stops working here for some reason
					game.Players:GetPlayerByUserId(receiptInfo.PlayerId).leaderstats.Donation.Value > 9999 and game.Players:GetPlayerByUserId(receiptInfo.PlayerId).leaderstats.Donation.Value < 100000  and not game.Players:GetPlayerByUserId(receiptInfo.PlayerId).Character.Head:FindFirstChild("BigDonator") then
					local char = game.Players:GetPlayerByUserId(receiptInfo.PlayerId).Character
					local Storage = game:GetService("ReplicatedStorage").nameTags
					local Gui = Storage.BigDonator:Clone()
					char.Head:FindFirstChild("Donator"):Destroy()
					Gui.Parent = char.Head
					Gui.Adornee = char.Head
				elseif
					game.Players:GetPlayerByUserId(receiptInfo.PlayerId).leaderstats.Donation.Value > 99999 and game.Players:GetPlayerByUserId(receiptInfo.PlayerId).leaderstats.Donation.Value < 1000000  and not game.Players:GetPlayerByUserId(receiptInfo.PlayerId).Character.Head:FindFirstChild("HugeDonator") then
					local char = game.Players:GetPlayerByUserId(receiptInfo.PlayerId).Character
					local Storage = game:GetService("ReplicatedStorage").nameTags
					local Gui = Storage.HugeDonator:Clone()
					char.Head:FindFirstChild("Donator"):Destroy()
					char.Head:FindFirstChild("BigDonator"):Destroy()
					Gui.Parent = char.Head
					Gui.Adornee = char.Head  
				elseif
					game.Players:GetPlayerByUserId(receiptInfo.PlayerId).leaderstats.Donation.Value > 999999 then
					local char = game.Players:GetPlayerByUserId(receiptInfo.PlayerId).Character
					local Storage = game:GetService("ReplicatedStorage").nameTags
					local Gui = Storage.MilDonator:Clone()
					char.Head:FindFirstChild("Donator"):Destroy()
					char.Head:FindFirstChild("BigDonator"):Destroy()
					char.Head:FindFirstChild("HugeDonator"):Destroy()
					Gui.Parent = char.Head
					Gui.Adornee = char.Head  
				end
				return Enum.ProductPurchaseDecision.PurchaseGranted end

If you have any questions, feel free to ask

It has to be the way you’re doing the checks. Try putting an else right before the “end” at the bottom and print something within that. If it does successfully print, then that means all your above checks are not returning true.

It might help you a little bit to make some variables so your if statements aren’t so long :slightly_smiling_face:

1 Like

Instead of just using a print("blah blah blah") statement, you should print the value of game.Players:GetPlayerByUserId(receiptInfo.PlayerId).leaderstats.Donation.Value to see what the actual value is.

I’ve added the else at the end but it won’t print. For some reason only the if and the first elseif statement works(“Donator and BigDonator”). I’m not sure if this is a studio bug

It looks like to me that you have not properly defined

receiptInfo.PlayerId