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

It works in Local but not when published and tested online?

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)

http://i.imgur.com/tXlIaJt.png

2 comments

0

By "local server" do you mean "Test Solo" or "Test Server"? See https://scriptinghelpers.org/blog/it-works-in-studio-but-not-online

0

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.

1 answer

I really only scanned the code, so I'm probably wrong here, but did you hook up mouse to game.Players.LocalPlayer:GetMouse()?

Or it could be that you are trying to use something before it has loaded, such as the character. Really, there are quite a few possibilities, so you should probably check out the latest blog.

1 comment

0

Where exactly should I put that, Im a newbie, sorry. :/

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