Lights not working

Hey, i am new to scripting, and i am trying to create an effect in which when i press the key “R” i make some police lights flash, i am using a car base to assist with the scripting, and am using this line of code in particular question image im trying to change the value of “hmyes” so that image this code will run, in turn making the lights flash.

But its not working, im not sure what im doing wrong, if somebody could assist me on making this work, it would be much appreciated.

Once again, i am a new scripter with hardly any experience, so sorry if i am doing anything painfully wrong.

The second picture that you posted runs the condition only once, meaning that the code will not check to see if els.hmyes will change in the future. Instead, you should try something like this:

while els.hmyes.Value == true do
    wait()
    -- whatever else you need to do in the loop
end

Shall the lights only flash when the player sits inside the car? If so you might check out ContextActionService. It’s more effective and prevents that the lights flash when the player didn’t mean to let them flash, e.g. if he types ‘R’ in the chat.

thank you, i will try that in a bit, and will update this post afterwards.

Your problem here is that you are using mouse.keydown, and you shouldn’t be using that in the first place. UserInputService is a much better alternative.

Code Example:

   game:GetService("UserInputService").InputBegan:Connect(function(key)
      if key.KeyCode=Enum.KeyCode.R then
       --code
      end
   end)