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

Ko Sword Giver [closed]

Asked by 10 years ago

I need help on how to make a script on how to make a Sword Giver that only works on a number of KOs, should i use a local script or a Regular Script?

Locked by FearMeIAmLag, Muoshuu, and BlueTaslem

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

3 answers

Log in to vote
2
Answered by
nate890 495 Moderation Voter
10 years ago

Since there is really no reason to use a LocalScript here, I would use a Script instead. You can learn when and how to use a LocalScript here.

Assuming that you want the user that touches the button to get all the swords they are eligible for, you would do something like this:

local swords = { --Keep swords in a model called "Swords" and put the model inside of Lighting. Make sure the strings in this table are the same as the swords name.
--  [KOs] = "Sword Name"
    [0] = "Classic Sword";
    [10] = "Venomshank"
}

local swordGiver = script.Parent

swordGiver.Touched:connect(function(hit)
    local character = hit.Parent
    local player = game.Players:GetPlayerFromCharacter(character)
    if player and not character:FindFirstChild("HasSword") then
        local kos = player.leaderstats.KOs.Value
        for req, sword in pairs(swords) do
            if kos >= req then
                game.Lighting.Swords[sword]:clone().Parent = player.Backpack
            end
        end
        Instance.new("ObjectValue", character).Name = "HasSword"
    end
end)

In order for the character to update/receive the swords that they are eligible for they must reset their character because the "HasSwords" ObjectValue needs to be removed (from their character.)

Hope this helps!

0
Ill try this matt10010010010 0 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Just do this, get a leaderboard, get the gui like Firebrand:100 kos Swordcane: 5 those kind of things in startergui, then put all the swords you have in lightning (The ones that are in the gui like firebrand,swordcane insert that and put it in lightning

Log in to vote
-1
Answered by 10 years ago

Try something like this.

requiredkos = 0
script.Parent.Touched:connect(function(h)
    if h.Parent:findFirstChild("Humanoid") then
        local human = h.Parent:findFirstChild("Humanoid")

        if human.Health > 0 then
            local p = game.Players:GetPlayerFromCharacter(human.Parent)

            if p:findFirstChild("leaderstats") then
                local kos = p:findFirstChild("KOs")

                if kos and kos.Value > requiredkos then
                    --give them the sword
                end
            end
        end
    end
end)
0
Im trying to make one for like 10 Kos = VenomShank and so on matt10010010010 0 — 10y