Jump to content

Flashlight script doesn't work anymore

Recommended Posts

Hello everyone,

I was working on a premade LUA script of FPS and I found flashlight script, really nice wink.png


However I can't make it work in my personal project. I used this part of the script which is completely correct:


if window:KeyHit(Key.F) then
if self.flashlight:Hidden() then


The flashlight works, the sound is correctly played, however when I hit again the F key the flashlight doesn't turn off but the light becomes brighter and brighter.









What am I missing ?


Thank you again for your precious support !

Share this post

Link to post

Check the part where you create the Flashlight.


Looks like everytime you press F you are creating another flashlight.

Share this post

Link to post

The code you provided looks fine actually. My guess is, like Josk says, that there might be some code somewhere else that conflicts with the code you are currently showing.

Share this post

Link to post

Can you send the project via pm? I will have a quick look. Also if you send it, remove assets that are nogt required for me to test the level. (Sound or large terrain textures for instance).

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...