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

I cant give players backpack item?

Asked by 5 years ago

Alright, so I was trying to make a script where if you reach 10000 strength, the game puts a new tool in your backpack. Here is the main part:

local strength = Instance.new("NumberValue")
    strength.Name = "Strength"
    strength.Parent = leaderstats
    print("Strength Loaded!")
    if strength.Value == 10000 then
        local bar = serverStorage.Tools.SteelBar
        bar.Parent = player.Backpack
    end

doesnt seem to work tho.

2 answers

Log in to vote
1
Answered by
royee354 129
5 years ago
Edited 5 years ago

1) You should clone that tool before parenting it 2) When you're showing us variables make sure we know what they are 3) The if statement runs right after you just parented the value, I'd suggest linking a Changed event of the Value to a function and checking then if the strength is 10000 or wtever u wanted it to be like so:

strength.Changed:Connect(function()
    if strength.Value == 10000 then
        local tool = game.ServerStorage.Tools.SteelBar:Clone()
        tool.Parent = Player.Backpack
    end
end)
0
I put that in my script and corrected the errors but I still have a few issues RowanStrohmYT 2 — 5y
0
you could just loop the if statement, but that wouldn't be performance friendly EmbeddedHorror 299 — 5y
0
also u could use :GetPropertyChangedSignal("Value") EmbeddedHorror 299 — 5y
Ad
Log in to vote
-2
Answered by 5 years ago
Edited 5 years ago

Where is leaderstats in the game files?

Have you defined player?

It's ServerStorage not serverStorage

Please have a look at the output before asking, it should give you a lot of info to work with.

Answer this question