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

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

Asked by 10 years ago

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

Log in to vote
0
Answered by 10 years ago

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.

Ad
Log in to vote
0
Answered by
hiccup111 231 Moderation Voter
10 years ago

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

Answer this question