#Why is the click not registered?

1 messages · Page 1 of 1 (latest)

covert garden
#

I'm making a script for a tool for the player and it should switch between 2 states by clicking, but it doesn't register the first click. I'm new to programming in Lua and I need help with this

covert garden
# spiral locust We need to see the code

local MiTool = script.Parent
local Emitor_De_Luz = script.Parent["Emitor de luz"]
local SpotLight = Emitor_De_Luz.SpotLight

local EstaEncendida = false

MiTool.Activated:Connect(function()
if EstaEncendida == false then
print("Linterna prendida")

    EstaEncendida = true
    
    Emitor_De_Luz.BrickColor = BrickColor.new("Institutional white")
    SpotLight.Enabled = true
elseif EstaEncendida ==  true then
    print("Linterna apagada")
    
    EstaEncendida = false
    
    Emitor_De_Luz.BrickColor =BrickColor.new("Black")
    SpotLight.Enabled = false

end

end)

covert garden
spiral locust
covert garden
#

That's exactly what I'm wondering, it's a flashlight switching between on and off but it only registers when the click is released but not when it is initially pressed

spiral locust
covert garden
#

yes yes

dark fjordBOT
#

studio** You are now Level 1! **studio

spiral locust
covert garden
#

no, it does not work

spiral locust
covert garden
#

MiTool.Activated:Connect(function()
if EstaEncendida == false then
print("Linterna prendida")

#

I know, here it is

spiral locust
covert garden
#

OHHH

#

Let me fix it and I'll come back, also thanks for telling me, I didn't know that.

dark fjordBOT
#

studio** You are now Level 8! **studio

rich crag
#

I mean im also a spanish speaker but its really odd looking at code like that

#

Also mind if i question why do you put [Emisor_De_Luz]?

#

At the end of giving a place to emisor de luz

#

Shouldn't it be just script.parent?

covert garden
#

That is the name of the object that emits the light

covert garden
rich crag
#

If its the parent of the script just do script.parent evilcat

#

you are gonna give an english speaker a stroke

#

lowk

#

But aight gl

#

Have you fixed it yet tho?

covert garden
#

local MiTool = script.Parent
local Emitor_De_Luz = script.Parent["Emitor de luz"]
local SpotLight = Emitor_De_Luz.SpotLight

MiTool.Activated:Connect(function()
--aqui la encendere
end)
MiTool.Deactivated:Connect(function()
--aqui no po
end)

#

It returns errors if I don't put "Emitor de luz"

rich crag
#

No idea, im also new and mostly i use script.parent

#

Or workspace: Waitforchild()

#

And it runs smoothly

#

Oh its because its a model

covert garden
#

can i send videos here?

#

Is it allowed?

spiral locust
covert garden
dark fjordBOT
#

studio** You are now Level 2! **studio

covert garden
#

I made the prints to demonstrate that the initial keystroke is not registered

spiral locust
#

Can you check the ManualActivationOnly property?

#

activación manual solamente

covert garden
#

I haven't read the documentation for that term yet, I'll go read it and tell you how it went.

spiral locust
#

"la característica" I think is the translation for english "Properties"

covert garden
#

ohhh

#

it's activated

spiral locust
covert garden
spiral locust
covert garden
#

OHHH

#

IT WORKED

#

What a simple solution, I feel a bit dum

spiral locust