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

Value not being named?

Asked by
hudzell 238 Moderation Voter
9 years ago
if not plr:FindFirstChild("Stats") then
    local stats = Instance.new("IntValue",plr)
        stats.Name = "Stats"

        wait(.1)

        local ad = Instance.new("IntValue",stats)
            repeat ad.Name = "Attack" wait() until ad.Name == "Attack" --This one is not being named attack, just Value
            ad.Value = math.random(60,80) --Also, it doesn't set this value. It basically just gets created, unchanged, then it just stops.

        wait(.1)
        print(ad.Name)

        local ap = Instance.new("IntValue",stats)
            repeat ap.Name = "Spell" wait() until ap.Name == "Spell" --This one is also not being named, just stays at Value
            ap.Value = 0

        wait(.1)
        print(ap.Name)

        local ar = Instance.new("IntValue",stats)
            ad.Name = "Armor"
            ad.Value = math.random(20,30)

        wait(.1)

        local mr = Instance.new("IntValue",stats)
            ap.Name = "MagicResist"
            ap.Value = math.random(5,20)

        wait(.1)

        local gd = Instance.new("IntValue",stats)
            gd.Name = "Gold"
            gd.Value = 0

        wait(.1)

        local lh = Instance.new("ObjectValue",stats)
            lh.Name = "LastHit"

        wait(.1)

        local bty = Instance.new("IntValue",stats)
            bty.Name = "Bounty"
            bty.Value = 0

        wait(.1)

        local mh = Instance.new("IntValue",stats)
            mh.Name = "MaxHealth"
            mh.Value = 900 + math.random(0,200)

        wait(.1)

        char:WaitForChild("Humanoid").WalkSpeed = 16 + (math.random(10)/10)

        script.PassiveGold.Disabled = false


end
0
Is there a reason why you're setting their names in repeat loops...? BlueTaslem 18071 — 9y
0
I am trying to make sure they are named that. It was an attempted fix. hudzell 238 — 9y

1 answer

Log in to vote
3
Answered by 9 years ago

Check that your names match up. You had this:-

local mr = Instance.new("IntValue",stats) 
ap.Name = "MagicResist" 
ap.Value = math.random(5,20) 

Instead of this:-

local mr = Instance.new("IntValue",stats) 
mr.Name = "MagicResist" 
mr.Value = math.random(5,20) 

And this one needs to be changed as well:-

local ar = Instance.new("IntValue",stats) 
ad.Name = "Armor" 
ad.Value = math.random(20,30)
0
Oh. Derp. I didn't even notice that. Thanks, it worked! hudzell 238 — 9y
Ad

Answer this question