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

Giver script help?

Okay I have created this script and it's working.

local coffee = script.Parent.Parent
local function OnMouseClick(Player)
	while true do
	coffee = script.Parent.Parent
	if Player == nil then return end
	coffee = game.ServerStorage.IceCoffee:Clone()
	if Player.Backpack:FindFirstChild(coffee.Name) ~= nil then return end
	coffee.Parent = Player.Backpack
	print("Enjoy your coffee!")
	end
	
end

script.Parent.MouseClick:connect(OnMouseClick)


But it only will let you click it once per life. I was wondering how I could fix this.

2 comments

1

You don't know? Just take out the if statement on line 07.

0

Thanks for the help percil I forgot about adding it I didn't pay attention to it!

1 answer

✓ Accepted answer

I'm not sure what use is the while true do, that could lead to your game crashing since there is no wait() and no real purpose for it. Also, you should make coffee = game.ServerStorage.IceCoffee in the beginning, remove all other coffee variables, and make it something like local c = coffee:Clone(), and have c.Parent = Player.Backpack. Hopefully this will work. The main error is the while true do existing in there.

2 comments

1

Reason I didn't include anything about that if statement at line 7 was because I assumed you only wanted each person to get 1 coffee.

0

I used the while true do loop to try and debug it myself. Percil helped me fix the problem thanks guys!

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