Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Bounty's Value Won't Increase, But Gems Value Will?

Whenever someone kills another player their "Bounty" goes up by one. But instead of doing that, the bounty doesn't change?! The Gem value and Kill value change though..!? I'm not getting any errors or anything, do you guys know what the fix would be?

Serverscript

game.Players.PlayerAdded:Connect(function(plr)
	
	
	MC = plr:WaitForChild("MainCurrency")
	
	local Bounty = MC:FindFirstChild("Bounty")
	
	LS = plr:WaitForChild("leaderstats")
	
	local Deaths = LS:FindFirstChild("Deaths")
	
	local Kills = LS:FindFirstChild("Kills")
	
	plr.CharacterAdded:connect(function(char) -- Kill Mechs

	local humanoid
		
		repeat
			humanoid = char:FindFirstChild("Humanoid")
			wait()
		until humanoid
		
		humanoid.Died:connect(function()
			
			local tag = humanoid:FindFirstChild("creator")
			
			if tag and MC and LS then
				
				local killer = tag.Value
				
				if killer then
					
					Deaths.Value = Deaths.Value + 1
					
					local KMC = killer:FindFirstChild("MainCurrency")
					
					local Bounty = KMC:FindFirstChild("Bounty")
					
					if killer.MainCurrency.Bounty.Value < 100 then
						
						killer.MainCurrency.Bounty.Value = 			killer.MainCurrency.Bounty.Value + 1
					
						killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value
					
						Bounty.Value = Bounty.Value - Bounty.Value
						
						killer.MainCurrency.Gems.Value = killer.MainCurrency.Gems.Value + 1
					
					end
				end
			end
		end)
	end)
	
end)

5 comments

0

Kills Value Won't Change Either**

0

Bounty.Value = Bounty.Value - Bounty.Value thats like saying 0 = 0 - 0

0

Which part won't update? The leaderstats or the values inside the player?

0

The value inside the player

0

just remove line 45

1 answer

✓ Accepted answer
  1. Kills won't change because you're not adding anything to the value, you're just setting it equal to itself.
  • It's basically saying 0 = 0, instead of 0 = 0 + 1

  1. Bounty, like greatneil80 said, you're subtracting the value from itself instead of adding it.
  • It's basically saying 0 = 0 - 0, instead of 0 = 0 + 100.

To Fix This


Change line 43 to this

killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1

This will add 1 to the current value of kills.


Change line 45 to this

Bounty.Value = Bounty.Value + 1

This will add 1 to the current value of bounty.


Hope this helped! If this fixed you're script, let me know by selecting this as the answer!

This discussion is preserved as it was. New answers, comments, and votes are closed.