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

Is it possible to check for values under scripts? In other words, script to script communication

Is it possible to have two local scripts, located within a player model, that are able to check for values between one another? For instance, a player has a "MainPlayer" localscript and a "Weapon" localscript. I want the Weapon localscript to check for a child under the "MainPlayer" localscript (not a function or anything, just a RemoteEvent that MainPlayer is the parent of), is this possible?

Here's my attempt at trying:

local MainPlayer = script.Parent.Parent.Parent:WaitForChild("MainPlayer") local Guarding = MainPlayer:WaitForChild("Guarding")

From a ServerScript within a LocalScript that is a child of a Tool, I'm trying to get this script to wait for a RemoteEvent named "Guarding" that is located under another LocalScript under the Player, which is the Parent of the tool.

2 comments

0

RemoteEvent is for client-server and server-client, therefore "remote", BindableEvent are for server-server

0

oh, you can also use _G or shared but i don't think they're very reliable

1 answer

Hello, Saevitiae!

Short answer: Yes. And your code should work.

Longer answer:

You need to be careful with how that script was created/moved. If it was done by the client, then most likely the server doesn't know its there. If it was done by the server, then the client 100% knows its there.

Useful links:

Roblox Client-Server Model


If this answers your question, please mark it as the accepted answer.

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