Is anything wrong with this script?

hi, im just trying to figure out if anything i did is wrong

script.Parent.MouseButton1Click:Connect(function()
Slot1.MouseButton1Click:Connect(function()
		keyWordTable["AttackKey"] = Enum.KeyCode.Q
	end)
end)
script.Parent.MouseButton1Click:Connect(function()
Slot2.MouseButton1Click:Connect(function()
		keyWordTable["AttackKey"] = Enum.KeyCode.E
	end)
end)

Thank you

1 Like

Why are you putting a click event inside of a click event? Can’t you just put them separate?

But im not sure where to put it?

local keyWordTable = {
	["AttackKey"] = Enum.KeyCode.E 
}
script.Parent.MouseButton1Click:Connect(function()
Slot1.MouseButton1Click:Connect(function()
		keyWordTable["AttackKey"] = Enum.KeyCode.Q
	end)
end)
script.Parent.MouseButton1Click:Connect(function()
Slot2.MouseButton1Click:Connect(function()
		keyWordTable["AttackKey"] = Enum.KeyCode.E
	end)
end)

You may add what script.Parent is (ClickDetector, …) or keyWordTable as well.

And also, please provide us a bit of context, what you intend to do, …

Can’t you just do

local keyWordTable = {
	["AttackKey"] = Enum.KeyCode.E 
}

Slot1.MouseButton1Click:Connect(function()
	keyWordTable["AttackKey"] = Enum.KeyCode.Q
end)

Slot2.MouseButton1Click:Connect(function()
	keyWordTable["AttackKey"] = Enum.KeyCode.E
end)

So im trying to make sure the player clicks the gui to active a skill

if i did that then when a player equips two skills the skills would mix up and break

Understandable, but why are putting them separating anyways, just put them i nthe connecting event. Also, you have to do some disconnection since it’ll make the event multiple times if ou click multiple times

local keyWordTable = {
	["AttackKey"] = Enum.KeyCode.E 
}

local slot1connect, slot2connect

script.Parent.MouseButton1Click:Connect(function()
	if slot1connect then slot1connect:Disconnect() end
	if slot2connect then slot2connect:Disconnect() end
	
	slot1connect = Slot1.MouseButton1Click:Connect(function()
		keyWordTable["AttackKey"] = Enum.KeyCode.Q
	end)
	
	slot2connect = Slot2.MouseButton1Click:Connect(function()
		keyWordTable["AttackKey"] = Enum.KeyCode.E
	end)
end)
1 Like

But when i do that it does this? The q button becomes disabled and only e works and combines the moves

That’s odd, it should work, I think you probably have to separate them again then or just go back to your original script if it worked since there didn’t seem to be any major issue besides not disconnecting if it already exists and the nset it again

i tried changing a few things but it still does that im really confused at this point

Any errors? Have you checked the name and the variables?

Then I believe it’s best you return it to how it was before since I presume it was working fine before

oh, before this it wasn’t working.

1 Like

i don’t see any errors in the output

What wasn’t working exactly in your script?

there weren’t any outputs but it was just combining the skills and disabling one of the keys

Tried using debounce? (I don’t think it has anything to do with it but still try)

but i already have debounce on both of the scripts?

Are you referring to the one I sent or the one you posted as the first post? It’s quite odd taht it’s not working