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

Leaderboard Kills/Level up, help?

I am making a battle royale game and... after you get a kill you see what you will be awarded with but I don't know what to use to connect the function with the game. Also, at line 33 = is underlined with a red colour, help?

local kills = Instance.new("IntValue")
local deaths = Instance.new("IntValue")
local credits = Instance.new("IntValue")
local level = Instance.new("IntValue")
local wins = Instance.new("IntValue")

kills.Name = "Kills"
deaths.Name = "Deaths"
credits.Name = "Credits"
level.Name = "Level"
wins.Name = "Wins"

kills.Value = 0
deaths.Value = 0
credits.Value = 0
level.Value = 0
wins.Value = 0

function onKill()
	kills.Value = kills.Value + 1
	credits.Value = credits.Value + 15
end

-- What do I have to add here? Like, ...:connect(function(onKill)

function onDeath()
	deaths.Value = deaths.Value + 1
end

Humanoid.Died:connect(function(onDeath)

function on2wins()
	if wins.Value = 2 then --At this line, = is underlined with red, what should I use there?
		level.Value = 1
		credits.Value = 100
	end
end

wins.Changed:connect(function(on2wins)

1 comment

0

Because it's wins.Value == 2 not = 2

2 answers

✓ Accepted answer

the = operator SETS a variable, not compare

the == operator COMPARES two values and returns a boolean, as hulabee and incapaz are pointing out

also, trying to detect a kill is very hard, i would suggest adding code at where the tools (weapons) do damage to a humanoid, by adding an "if" for when the the health is taken for detecting if the health is <= 0 and sending a message to this script perhaps via RemoteEvents that the player has killed another player, and connect onKill with the message

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