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

How do you use a "if" statement while checking for their kills?

Asked by 3 years ago
Edited 3 years ago

Right now I'm trying to make a script that checks if your kills is above 10 then it'll replicate the sword.

But at the moment, even if your kills are above 10 it'll still display the "Bloodlust is weak" text. It's a server script.

If I can't use a if statement to check their kills, how would I check their kills and make sure they have more than the required kills to give the sword?

    Players = game:GetService("Players")
click = script.Parent
RS = game.ReplicatedStorage
waittime = 3

Players.PlayerAdded:Connect(function(player)
    repeat
        wait()
    until
    player.Character
    text = player.PlayerGui.ShowKills.DisplayText.Text1
    showkills = player.PlayerGui.ShowKills.DisplayText
    local kills = player.leaderstats.Kills

    click.MouseClick:Connect(function()
        if kills.Value >= 10 then
            text.Text = "You have evolved.."
            showkills.Visible = true
            wait(waittime)
            showkills.Visible = false
        else
            text.Text = "Your bloodlust is weak."
            showkills.Visible = true
            wait(waittime)
            showkills.Visible = false
        end
    end)
end)

2 answers

Log in to vote
0
Answered by 3 years ago

Hi. I think it is because u wrote that if the player has EXACTLY 10 kills then they will get the sword. So to make it 10 and above you would have to do this:

    click.MouseClick:Connect(function()
        if kills.Value >= 10 then
            text.Text = "You have evolved.."
            showkills.Visible = true
            wait(waittime)
            showkills.Visible = false
        else
            text.Text = "Your bloodlust is weak."
            showkills.Visible = true
            wait(waittime)
            showkills.Visible = false
        end
    end)
end)

0
Still didn't work and still displays the "Bloodlust is weak" text. I updated the thread with the full code incase i messed up something. kegirosou 17 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
    click.MouseClick:Connect(function()
        if kills.Value >= 10 then -- so now its if kills value is bigger or equal to 10
            text.Text = "You have evolved.."
            showkills.Visible = true
            wait(waittime)
            showkills.Visible = false
        else
            text.Text = "Your bloodlust is weak."
            showkills.Visible = true
            wait(waittime)
            showkills.Visible = false
        end
    end)

you had 3x end but you need just 2 (end - if statement, end) - function)

and as purplxboi said, you need exactly 10 kills, so if you have more you wont be able to evolve

Answer this question