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

Understanding of local and non local scripts?

Do scripts function separately to each individual player? So, if i set a variable to a player's name as he joins, will the variable hold the own user's username, or will the variable change if another player joins?

Or does this vary whether it is inside a local script or a normal script? I don't quite know the difference.

3 comments

0

local scripts are for your player, server scripts are for all the players

0

if you have FE enabled then you create a part when a object is touched you are the only one that will see it if you use a localscript, if you use a server script with the same code all players will see it

0

Thank you for clearing this out for me.

1 answer

Scripts run on the server side while local scripts run on the client side. Say you wanted to make a simple leader-board you would use a normal script. If you were creating a Gui you would use a local script. Local scripts can ONLY be used for the player. Local scripts are for a single player. Scripts are for everyone in the server. Example:

game.Workspace.Baseplate.BrickColor = BrickColor.new("Lime green")

This code on a normal script would change the color of the baseplate to green. If this was a local script it would only change it for the client (Your device). This script would be no different to a normal script because it executes as soon as the player joins so the color would be the same for all players. If I was to add a wait(10) in the code it would wait 10 seconds then change the color. For a player that has been on the server for at least 10 seconds it would be green.

Let me give a better example:

game.Workspace.Baseplate.Touched:connect(function()
	game.Workspace.Baseplate.Material = Enum.Material.Slate
end)

This would only execute locally if you used a local script. Remember local scripts can ONLY be used in the player. This means they will not execute in Workspace.

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