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

Localscript not working online or in server, but it works in test mode?

It's a localscript. It works in test mode, but not online or in a server.

MainButtons = script.Parent.MainButtons
TeamsFrame = script.Parent.Teams
Store = script.Parent.Store
Credits = script.Parent.Credits
PlayGame = MainButtons.PlayGame

-- Open Teams Frame
function onClickedChangeTeam()
	if TeamsFrame.Visible == true then
		-- TeamsFrame is visible, close it
		TeamsFrame:TweenPosition(UDim2.new(0.3,0,1,0), 'Out', 'Sine', 1)
		TeamsFrame.Visible = false
	elseif Store.Visible == false and Credits.Visible == false then
		-- if everything is closed, open it
		TeamsFrame.Visible = true
		TeamsFrame:TweenPosition(UDim2.new(0.3,0,.35,0), 'Out', 'Sine', 1)
	elseif Store.Visible == true or Credits.Visible == true then
		-- somethings open
		if Store.Visible == true then
			--make the store invisible, flashy exit
			-- flashy exit
			Store.Visible = false

			--enter TeamsFrame
			TeamsFrame.Visible = true
			TeamsFrame:TweenPosition(UDim2.new(0.3,0,.35,0), 'Out', 'Sine', 1)
		else
			--must be the Credits that are open, eh?
			-- flashy exit
			Credits.Visible = false

			--enter TeamsFrame
			TeamsFrame.Visible = true
			TeamsFrame:TweenPosition(UDim2.new(0.3,0,.35,0), 'Out', 'Sine', 1)

		end

	end
end

-- Open Store Frame
function onClickedOpenStore()
	if Store.Visible == true then
		-- Store is visible, close it
		Store:TweenPosition(UDim2.new(0.3,0,1,0), 'Out', 'Sine', 1)
		Store.Visible = false
	elseif TeamsFrame.Visible == false and Credits.Visible == false then
		-- if everything is closed, open it
		Store.Visible = true
		Store:TweenPosition(UDim2.new(0.3,0,.35,0), 'Out', 'Sine', 1)
	elseif TeamsFrame.Visible == true or Credits.Visible == true then
		-- somethings open
		if TeamsFrame.Visible == true then
			--make the store invisible, flashy exit
			-- flashy exit
			TeamsFrame.Visible = false

			--enter TeamsFrame
			Store.Visible = true
			Store:TweenPosition(UDim2.new(0.3,0,.35,0), 'Out', 'Sine', 1)
		else
			--must be the Credits that are open, eh?
			-- flashy exit
			Credits.Visible = false

			--enter TeamsFrame
			Store.Visible = true
			Store:TweenPosition(UDim2.new(0.3,0,.35,0), 'Out', 'Sine', 1)

		end

	end
end

----

--

MainButtons.ChangeTeam.MouseButton1Click:connect(onClickedChangeTeam)
MainButtons.Store.MouseButton1Click:connect(onClickedOpenStore)
--[[
	PLAY SOUND IF HOVER

--]]
function PlaySound()
	script.Parent.Select:Play()
end
MainButtons.ChangeTeam.MouseEnter:connect(PlaySound)
MainButtons.Store.MouseEnter:connect(PlaySound)
MainButtons.Credits.MouseEnter:connect(PlaySound)
MainButtons.PlayGame.MouseEnter:connect(PlaySound)

2 comments

0

try using a normal script then?

0

Ye, just use a server script

1 answer

The difference between server scripts and local scripts

Local scripts are used to control client-side things, these may include the mouse and the camera. These also run on the client, so it is not recommended to store points, wins, money, etc. as that could be edited. However, server scripts are used to access data stores and other things. These also run on the server


How StarterGui works

Placing a gui in StarterGui will copy it to the player's PlayerGui object located inside the player object. This means that it has a copy stored on the server, not the client. As a result, a local script is not required as it is not really to do with the client. It can all be edited with a server script.


Thanks for reading

Thank you for reading my answer. If it helped, please upvote it and accept it! Thanks!

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