Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Leaderboard Kills/Level up, help?

Asked by 6 years ago

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)
0
Because it's wins.Value == 2 not = 2 User#19524 175 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

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

Ad
Log in to vote
0
Answered by 6 years ago

Try replacing line 33 with this code.

if wins.Value == 2

0
Comment. User#19524 175 — 6y

Answer this question