Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I cant give players backpack item?

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

  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)

3 comments

0

I put that in my script and corrected the errors but I still have a few issues

0

you could just loop the if statement, but that wouldn't be performance friendly

0

also u could use :GetPropertyChangedSignal("Value")

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.