Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Understanding of local and non local scripts?

Asked by 6 years ago

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.

0
local scripts are for your player, server scripts are for all the players DevingDev 346 — 6y
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 DevingDev 346 — 6y
0
Thank you for clearing this out for me. DzoJung 2 — 6y

1 answer

Log in to vote
0
Answered by
zblox164 531 Moderation Voter
6 years ago

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.

Ad

Answer this question