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

Tool cloned from replicated storage to the player's backpack doesn't work like the original does?

So I am making a shop and when you buy it, it of course gives you the item but then the item that is cloned to your inventory doesn't actually work as it supposed to. I have even moved the tool to my StarterPack and it works fine but when I put it in the shop it just doesn't work. This is the script inside the tool.

local Smasher = script.Parent
local Tool = Smasher.Parent
local PlayerModel = Tool.Parent.Parent
local Player = game.Players:FindFirstChild(PlayerModel.Name)

local debounce = false
local timer = 1
if debounce == false then
	debounce = true
	Smasher.Touched:Connect(function(hit)
		if hit.Name == "SodaBottle" then
			hit.Health.Value = hit.Health.Value - 25
			if hit.Health.Value <= 0 then
				hit:Destroy()
				if Player.Sodas.Value < Player.MaxSodas.Value then
					Player.Sodas.Value = Player.Sodas.Value + 1
				end
			end
		end
	end)
	wait(timer)
	debounce = false
end

1 comment

0

What does the tool do, and what is it supposed to do?

1 answer

While examining your script, I did not find any part in which the tool is cloned and given to player.

You can add a line inside Touched Event:

local player = game.Players:GetPlayerFromCharacter(hit.Parent)

add a line to the place where you increase your leaderstats value:

local clone = Tool:Clone()
local backpack = player:WaitForChild("Backpack")
clone.Parent = backpack

Lemme know if it helps!

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