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

How do you trigger something in one script from an event that happened in another?

Okay, I'm gonna try to describe this as good as I can. If I had a main game script, and then I waited for a Gui (that has a script in it) to be clicked before the rest of the script could go on., how would I do it? But while doing that, I would also need the Text of the Gui to be transfered to the main script too.

So, is there a way to transfer info from script to another? (Again, I'm sorry if I didn't put enough description into this. This is kinda hard to put into words.)

2 answers

You could use global variables

Ex.

Brick.Touched:connect(function(hit)
 _G["Touched"] = true -- set the global variable to true
end)

Other script

while _G.Touched == true then
 -- Code
 break; -- make the while loop run once
end

If this helped please up vote me answer thanks.

Could use a BooleanValue:

BoolValue.Changed:connect(function() If not BoolValue.Value then return end

	-- Code

end)

If both scripts are of the same type, (LocalScript / Normal Script), you could use Global Functions:

function _G.NameOfFunction( )

	--Code

end

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