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

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

Asked by 2 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

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.

0
RemoteEvent is for client-server and server-client, therefore "remote", BindableEvent are for server-server RAFA1608 543 — 2y
0
oh, you can also use _G or shared but i don't think they're very reliable RAFA1608 543 — 2y

1 answer

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
2 years ago

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.

Ad

Answer this question