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

How to have a script execute at a certain amount in Leader stats?

Asked by 6 years ago

For example if you get 10 kills I want it to execute the script

0
Any script..? hellmatic 1523 — 6y
0
Please post some code so it is easier for us to help you fix it, this is help site not a request site. Galicate 106 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
local Players = game:GetService("Players")

function onPlayerAdded(player)
kills = player.leaderstats.[Stat's name here, no brackets]
if kills == 10 then

[Remove this part and these brackets and insert your script here]

end

Next time your asking for something.

EXPLAIN YOURSELF.

Not just a simple "i wunt dut wun i hav 10 keels a scrept hoopans"

No, you need to say stuff like.

"I want that when my leaderstat value "kills" gets into a certain value, a script gets triggered, There is the script i want to get triggered:"

INSERT YOUR FLIPPING SCRIPT HERE.
0
That will not work. Not even close. Local variables are long deprecated. DeceptiveCaster 3761 — 6y
Ad
Log in to vote
-1
Answered by 6 years ago
Edited 6 years ago
_G.char = game.Players.LocalPlayer.Character
game.Players.PlayerAdded:Connect(function()
    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"
    stats.Parent = char.Backpack
    local kills = Instance.new("IntValue")
    kills.Name = "Kills"
    kills.Parent = stats
    kills.Value = 0
end)
if char.Backpack:FindFirstChild("Kills") ~= nil then
    k = char.Backpack:FindFirstChild("Kills")
    if k.Value >= 10 then
        if game.Workspace.TriggerScript.Disabled ~= false then -- What could be the script that fires
            game.Workspace.TriggerScript.Disabled = false
        end
    end
end

Is this what you're talking about?

Answer this question