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

How would I connection this function for this script?

I'm a bit confused with this, I don't know how would I connect this script which would give the tool to the player once, the number value reaches zero.

local wood = game.ServerStorage.WoodStorage.Wood
local hits = script.Parent.Hits
part = script.Parent
function Wood(Player)
while wait() do
if hits.Value == 0 then
wood:clone()
wood.Parent = Player.Backpack
part:Destroy()
end
end
end
script.Parent.Hits:connect(Wood)

The error is the last line connect is not a valid member of NumberValue Help and explain.

1 answer

✓ Accepted answer

An important part of learning how to program is learning how to read documentation.

Go to the Wiki entry for NumberValue.

There is a section called Events. Which event looks like it would let us detect when the value becomes 0?




Once you've found it, take a look at the example.

Your script has a few problems. There's no where for Player to come from, and you shouldn't be mixing a while wait() do loop with an event -- you usually only need on or the either.

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