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

A few questions regarding Local scripts (do services and events work in ls?)

Asked by 4 years ago

Hello! I just have a few questions regarding local scripts.

When i parent the script to StarterPlayerScripts and I include a script with

game.Workspace.Part.Touched:Connect(function()

    --stuff here that only the player can see(not seen by others)

end)

the script works. but is it better to use a script parented to serverscriptservice instead and use a remote event/function? i'm not sure which to use. Can anybody tell me which is better? Also can all events such as TouchedEvent work in local scripts? (parented to startercharacter/starterplayer)

another question: Do services work in localscript? Such as PathfindingService. For some reason, I wrote a pathfinding script in localscript parented to startercharacter and it didn't work. But it works if it's in a normal script in serverscriptservice.

please help answer both questions!

I appreciate all help! Thanks for your time!

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Well, you can use Touched events in Local Scripts. But, it is not recommended to use it client-sided because there can be exploitation, also, if you use Remote Event, firing it too much might result in Server lag.

workspace.Part.Touched:Connect(function()

    print("GG") -- It will print in Client side and not on Server

end)

Also, there are some services that you can use in Client-Side. These services include, UserInputService and many more. Also, there are certain services that you can't use, which includes, DataStore.

Also, you stated about PathFinding. The reason why it didn't work is that the computation of the path should be done Server-sided and cannot be done on Client-Side. Although, you can move the model in Client-Side.

Lemme know if it helps!

0
Thank you so much! You helped a ton! Gmorcad12345 434 — 4y
Ad

Answer this question