I have made a tool, and when I test it out by putting it in StarterPack, it works as it should, but when I put it in ReplicatedStorage, and use a TextButton to 'buy' it, it gives me the tool, except it does not work. At first, I thought it was because the children weren't cloning, so I changed the script. I can see that the children are cloning because while testing I can press on the player's backpack and it's there in full. I have no idea why it doesn't work.
This is the Button script:
local player = game.Players.LocalPlayer
local storage = game:GetService("ReplicatedStorage")
local bottle = storage:WaitForChild("Fast")
local backpack = player.Backpack
script.Parent.MouseButton1Click:Connect(function()
if player.leaderstats.Sips.Value >= 30 then
player.leaderstats.Sips.Value -= 30
local bottleClone = bottle:Clone()
bottleClone.Parent = backpack
end
end)
This is the Tool's script:
local tool = script.Parent
local canClick = true
local function onClick()
if canClick then
canClick = false
local str = Instance.new("StringValue")
str.Name = "toolanim"
str.Value = "Slash"
str.Parent = tool
local player = game.Players:FindFirstChild(tool.Parent.Name)
player.leaderstats.Sips.Value = player.leaderstats.Sips.Value + 2
wait(1)
canClick = true
end
end
tool.Activated:Connect(onClick)
