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

Can somebody explain the full difference between Script and Local Script?

Asked by
TMGOR 20
5 years ago

So I tried to use LoadCharacter() and apparently that doesn't work on local scripts, and using LocalPlayer doesn't work on scripts and I'm getting really confused now and I can't find and good answers on the internet. Can someone please expalin it?

0
script: for the server local script: client hellmatic 1523 — 5y

2 answers

Log in to vote
2
Answered by 5 years ago

Hi TMGOR,

There are some methods that are only designed for local scripts just because of security or the way that studio works. LocalScripts are basically scripts that clone to the client... so, the client would be my computer and the local script would be on my side. Then, just 'Script' is called a ServerScript, which means that these scripts stay on the Server. LocalPlayer can only be accessed by LocalScripts because they are the ones on the client and LocalPlayer is the client's player. That's the basic difference between Local and Server scripts... Just remember that some methods can only be used on client side and some can only be used on the server side. If you think this is complicated then good luck with FilteringEnabled.

Well, hope I helped and have a nice day/night.

Thanks,

Best regards,

~~ KingLoneCat

0
That's literally what I just summarized. Sheesh. DeceptiveCaster 3761 — 5y
0
I was writing mine out while you were writing yours out. I hadn't seen yours until I posted mine. KingLoneCat 2642 — 5y
0
Methods being usable only by LocalScripts for "security purposes" makes no sense; a hacker can inject whatever LocalScript they want, which could make use of these functions. The reason some features are client-only is because it doesn't make any sense for the server. If a method was to be secure, it would be accessible from the *server* only, not the client. Link150 1355 — 5y
Ad
Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Here's the juice you should know:

  • Regular Scripts are server wide and using methods like GetPlayerFromCharacter (which, by the way, you can only call from game.Players) will work because every player can apply to that method. Using Scripts enables every player to see something and not just one player (like the for loop used for the PlayerGui).

  • Local Scripts only run on one player's computer and cannot be seen by other computers within a server. Directories such as "game.Players.LocalPlayer" are only compatible with LocalScripts and will NOT work with regular Scripts.

This is how you would use GetPlayerFromCharacter() by the way:

-- Regular Script
local part = script.Parent
bool = true
part.Touched:Connect(function()
    bool = false
    local p = game.Players:GetPlayerFromCharacter(part)
    if p then
        print(p.Name.." has touched me!")
    end
    wait()
    bool = true
end)
0
if bool == true then --> why would you need a debounce if you don't do that lol User#20388 0 — 5y
0
`Player.LocalPlayer` is not a "directory", it is a *property* -- and is part of individual player objects, not the Players service -- please learn the proper vocabulary if you wish to answer questions properly. "Regular Scripts are server wide and using methods like `GetPlayerFromCharacter` [...] will work because every player can apply to that method", that also doesn't make any sense. Link150 1355 — 5y

Answer this question