Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago
Edited 4 years ago

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

0
What does the tool do, and what is it supposed to do? SteamG00B 1633 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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!

Ad

Answer this question