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

Im trying to make a item picker.. BUT IDK WHAT THE PROBLEM IS??

local itemTable = {
	"Grass",
	"Diamond",
	"Gold",
	"Dirt",
}
local part = script.Parent
local click = part.Clicker
local db = false
click.MouseClick:Connect(function(clicked)
	if clicked.Parent:FindFirstChild("Humanoid") then
		local plr = clicked.Parent
		if not db then
			if plr.leaderstats.Coins.Value >= 500 then
				local item = itemTable[math.random(1,#itemTable)]
				wait(2)
				print(item)
			end
		end
	end
end)

there are 0 errors but i want it to be where if you have over 500 then you are able to click a button then it chooses a random item? can someone help?

1 comment

0

You can always change who you accepted, that is if you want though..

2 answers

✓ Accepted answer

@greatneil80 has the correct explanation. I edited the code for you, but don't give me the credit because all I did was rewrite it. Great Neil is the one who provided an explanation so it is his answer you should accept.

Here is the code:

local itemTable = {
    "Grass",
    "Diamond",
    "Gold",
    "Dirt",
}
local part = script.Parent
local click = part.Clicker
local db = false
click.MouseClick:Connect(function(plr)
	if not db then
		if plr.leaderstats.Coins.Value >= 500 then
			local item = itemTable[math.random(1,#itemTable)]
			wait(2)
			print(item)
		end
	end
end)

2 comments

0

wont work ;-;

0

WAIT NEVER MIND MY CHARACTER JUST DIDNT HAVE ENOUGH COINS LOL

the variable clicked is the player not the character body part when you do .Touched, remove line 11 and change use clicked instead of plr

The parameter clicked should return the player if I'm not wrong.

2 comments

0

GREAT NEIL IM SO SORRY I ACCIDENTALLY ACCEPTED HISSS

0

bro unaccept his and accept mine :C

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