Hello, this has been confusing me since last night, the script works on Local (Studio Test) Server, but when I publish and start the game, it doesn't even work at all. The purpose of this tool's script is to add another tool that is in the tool. For example, the tool is named "More Tools" and this script is inside it alongside with about 5 other tools (Basically 5 tools + this script is the children). It should give one tool whenever clicked.
bin = script.Parent
backpack = bin.Parent
player = backpack.Parent
tools = {}
currentTool = 0
function onButton1Down(mouse)
if #tools == 0 then
print("ERROR: No Tools.")
return
end
if currentTool ~= #tools then
currentTool = currentTool + 1
else
currentTool = 1
end
if not tools[currentTool] then
print("ERROR: Tool not found.")
end
previousTool = currentTool - 1
if previousTool == 0 then
previousTool = #tools
end
--[[if tools[previousTool] then
if tools[previousTool].Parent == backpack then
tools[previousTool].Parent = bin
else
print("ERROR: Previous tool already in bin.")
end
else
print("ERROR: Previous tool not found")
end]]
local c = backpack:GetChildren()
for i = 1, #c do
for n = 1, #tools do
if string.sub(tools[n].Name,1,4) == string.sub(c[i].Name,1,4) then
c[i].Parent = nil
end
end
end
tools[currentTool]:Clone().Parent = backpack
end
function onSelected(mouse)
local c = bin:GetChildren()
for i = 1, #c do
if c[i].className == "HopperBin" or c[i].className == "Tool" then
table.insert(tools, c[i])
end
end
mouse.Button1Down:connect(onButton1Down)
end
bin.Selected:connect(onSelected)

2 comments
By "local server" do you mean "Test Solo" or "Test Server"? See https://scriptinghelpers.org/blog/it-works-in-studio-but-not-online
All 3, The F7 button on Studio, The "Play" button and by publishing the game and playing it directly from Roblox.com, the former 2 works. The last one does not.