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 If An Action Has Been Done In A Script And If So How?

This is pretty confusing so I'll explain the best I can.

What I Mean...

I want to know if it's possible to check if an action has been done in a Script (or Local Script), from another Script (Or Local Script). I want to see if an action has been done and if the action has been done, I want a piece of code to be executed.

For Example...

Let's say that if a player pressed a certain key on their keyboard such as 'L', then I want a code to be executed from another Script, say the print() function.

--Checks if player has pressed L

function  onKeyPress(inputObject,  gameProccessedEvent)

if inputObject.KeyCode == Enum.KeyCode.L then
game.Players.LocalPlayer.Character.Humanoid.Health = 0

     end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)
--Prints if L has been pressed

print('L has been pressed')

--not sure what to do...

Now...

I know I could put the print() function into the onKeyPress code but I just chose this example to have you guys see what I am trying to do, is there any way to actually do this? Thanks for trying to answer or tried to answer this.

Greek

1 answer

Sorta

Remote Events allows Script Communication between the server and client. While Filtering Enabled is on, clients can not communicate through user made local scripts, and the info must be sent to the server and back to another Client. Another option is using Module Scripts, but this is more of an extended function library, and I don't think this is what you mean. RBX.Lua disabled the G_ function so script communication is a little harder, but it's still possible.

Good Luck!

Not Sure If I provided the best answer, but if I did help, or if someone else helped, please don't forget to accept their/my answer.

2 comments

1

Thanks for that, helped a little :)

1

<3

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