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

How do I make this clone the tool ONLY when the tool was removed?

Currently, the tool is cloned even when the player had it never removed. I was told that nil would work best for checking if the player has the tool, but when I tested it without the tool, I still got the cloned tool. The goal of this is to have a frame come up. If the player has the needed tool, then the script would take the tool. If the player wants to cancel it, they would 'exit.' Even though the player did not have the tool starting out, they still got it. Localscript (finds if the player has the tool and then deletes it):

if localPlayer.Backpack:FindFirstChild("2 Cups of All-Purpose Flour") then
	item1.Text = "Used 2 Cups of All-Purpose Flour {Left with 0 Cups}"
	item1.BackgroundColor3 = Color3.fromRGB(255, 162, 162)
	item1.Visible = true
	game.Players.LocalPlayer.Backpack:FindFirstChild("2 Cups of All-Purpose Flour"):Destroy()
end

Second Localscript (gives the tool back upon mouse click):

button.MouseButton1Click:Connect(function()
	if game.Players.LocalPlayer.Backpack:FindFirstChild("2 Cups of All-Purpose Flour") == nil then
		local new = allPurposeFlour:Clone()
		new.Parent = game.Players.LocalPlayer.Backpack
	end
end)

2 comments

0

Tried this? if not game.Players.LocalPlayer.Backpack:FindFirstChild("2 Cups of All-Purpose Flour") then

0

I tried that, but it only works if the player does not start out with the tool.

1 answer

Try using:

if not game.Players.LocalPlayer.Backpack:FindFirstChild("2 Cups of All-Purpose Flour") then

Also, use remoteevents to clone the tools.

1 comment

0

Same thing with tictac67's answer. It does not work when the player starts out with the tool and then has it removed. As for remoteevents, I'll try that.

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