Tool giver gives player the original tool instead of the cloned tool?

  1. What do you want to achieve?
    I have a tool giver that is supposed to give the player a tool from ServerStorage. When a player uses the giver however it gives the player the original tool instead of the cloned tool.

  2. What is the issue?
    This creates a problem because if I were to destroy the tool in the player’s backpack/inventory then the original tool won’t be in ServerStorage anymore as it’d be destroyed.

  3. What solutions have you tried so far?
    I’ve tried searching the DevForum but I struggled to find a post that was specific to my situation. I also have tried rewriting my script but I’m not very confident in my abilities (as I’m very new to scripting) and nothing works.

local prp = script.Parent
local pizza = game.ServerStorage["Pupperoni Pizza"]

prp.Triggered:Connect(function(player)
	pizza:Clone()
	pizza.Parent = player.Backpack
	prp.Enabled = false
	wait(20)
	prp.Enabled = true
	
	end)

Screen Shot 2022-07-21 at 4.22.05 PM

1 Like

this line doesn’t set the new cloned tool as a variable use something liike this to clone it over

local NewPizza = pizza:Clone()
NewPizza.Parent = player.Backpack
1 Like

Use pizza:Clone().Parent = player.Backpack

2 Likes

Is this how I’d write it?

local prp = script.Parent
local pizza = game.ServerStorage["Pupperoni Pizza"]
local NewPizza = pizza:Clone()

prp.Triggered:Connect(function(player)
	pizza:Clone()
	NewPizza.Parent = player.Backpack
	--game.StarterPlayer["Pup Pizza"].Value = true
	prp.Enabled = false
	wait(20)
	prp.Enabled = true
	
	end)

like this

local prp = script.Parent
local pizza = game.ServerStorage["Pupperoni Pizza"]


prp.Triggered:Connect(function(player)
	local NewPizza = pizza:Clone()
	NewPizza.Parent = player.Backpack
	--game.StarterPlayer["Pup Pizza"].Value = true
	prp.Enabled = false
	wait(20)
	prp.Enabled = true

end)
1 Like

I was wondering if you could also help me with this related problem:

How would I delete the cloned tool from the player’s backpack? Once I “give” the tool to the NPC, I’d like the tool removed from their backpack but not the ServerStorage?

My script isn’t working :confused:

local pizzatool = game.Players.LocalPlayer.Backpack["Pupperoni Pizza"]
local pizza = game.Workspace.PupperoniPizza
local prp = script.Parent
local customer = prp.Parent

script.Parent.Triggered:Connect(function(player)
	if game.StarterPlayer["Pup Pizza"].Value == true then
		player.leaderstats.Money.Value = player.leaderstats.Money.Value + 25
		game.StarterPlayer["Pup Pizza"].Value = false
		pizzatool.Cheese.Transparency = 1
		pizzatool.Toppings.Transparency = 1
		pizzatool:Destroy()
	
	end
	end)

Screen Shot 2022-07-21 at 5.31.49 PM

I was wondering if you could maybe help me with this related problem?

How would I delete the cloned tool from the player’s backpack? Once I “give” the tool to the NPC, I’d like the tool removed from their backpack but not the ServerStorage?

My script isn’t working :confused:

local pizzatool = game.Players.LocalPlayer.Backpack["Pupperoni Pizza"]
local pizza = game.Workspace.PupperoniPizza
local prp = script.Parent
local customer = prp.Parent

script.Parent.Triggered:Connect(function(player)
	if game.StarterPlayer["Pup Pizza"].Value == true then
		player.leaderstats.Money.Value = player.leaderstats.Money.Value + 25
		game.StarterPlayer["Pup Pizza"].Value = false
		pizzatool.Cheese.Transparency = 1
		pizzatool.Toppings.Transparency = 1
		pizzatool:Destroy()
	
	end
	end)

Screen Shot 2022-07-21 at 5.31.49 PM

Try this if i am understanding what you are trying to do

local Player = game.Players.LocalPlayer
local pizza = game.Workspace.PupperoniPizza
local prp = script.Parent
local customer = prp.Parent



script.Parent.Triggered:Connect(function()
	if game.StarterPlayer["Pup Pizza"].Value == true then
		Player.leaderstats.Money.Value = Player.leaderstats.Money.Value + 25
		game.StarterPlayer["Pup Pizza"].Value = false
		local pizzatool = Player.Backpack:FindFirstChild("Pupperoni Pizza") or Player.Character:FindFirstChild("Pupperoni Pizza")
		if pizzatool then
			pizzatool.Cheese.Transparency = 1
			pizzatool.Toppings.Transparency = 1
			pizzatool:Destroy()
		end
	end
end)