When i click on a move, both moves play. How do i fix?

So in this video i made two seperate skills a rock and a energy ball type skill. But when i equip on one of them, they both play just like in the video. How do i seperate them? and how would i make it so if a new player equips a new skill in the same slot from the previous skill that they don’t both play


Heres the scripts

--I removed the variables for this just because they were too long
local keyWordTable = {
	["AttackKey"] = Enum.KeyCode.E -- set this to your default key
}

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

local guiWordTable = {
	["guikey"] = Skillslot1
}
Slot1.MouseButton1Click:Connect(function()
	guiWordTable["guikey"] = Skillslot1
end)
Slot2.MouseButton1Click:Connect(function()

	guiWordTable["guikey"] = Skillslot2
end)


function cameraShake()
	local Character = Player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
	
	for i=1, 30 do
		local a = math.random(-10,10)/100
		local b = math.random(-10,10)/100
		local c = math.random(-10,10)/100
		
		Humanoid.CameraOffset = Vector3.new(a,b,c)
		
		wait()
	end
	Humanoid.CameraOffset = Vector3.new(0,0,0)
end


UIS.InputBegan:Connect(function(input,isTyping)
	if script.Parent.Values.Equipped.Value == true then
		if isTyping then
			return
			elseif input.KeyCode == keyWordTable["AttackKey"] then
			if debounce == false then

				debounce = true
				guiWordTable["guikey"]:TweenSize(UDim2.new(1,0, 1, 0),"In","Linear", 0)
				detroit:FireServer()
				
			end
		end
	end
end)
---Cooldown---
detroit.OnClientEvent:Connect(function()
		local change = 1 - (last/cooldown)
		guiWordTable["guikey"]:TweenSize(UDim2.new(1,0, change, 0),"In","Linear", cooldown)
		wait(cooldown)
		debounce = false
end)

cam.OnClientEvent:Connect(function()
	cameraShake()
end)

game.StarterGui.MainGui.HUD.SkillsHolder.Slot1.TouchTap:Connect(function()
	if not debounce and script.Parent.Values.Equipped.Value then
		debounce = true
		detroit:FireServer()
	end
end)

And heres the energy ball script

local Player = game.Players.LocalPlayer

local UIS = game:GetService("UserInputService")
local rp = game:GetService("ReplicatedStorage")
local Kameha = rp.Events:WaitForChild("Kameha")

local active = false
local debounce = false

local cooldown = 2

local Slot1 = script.Parent.Parent.Parent.SlotLocation.Buttons.Slot1
local Slot2 = script.Parent.Parent.Parent.SlotLocation.Buttons.Slot2
local Skillslot1 = script.Parent.Parent.Parent.Parent.Parent.Parent.HUD.SkillsHolder.Slot1.CooldownE
local Skillslot2 = script.Parent.Parent.Parent.Parent.Parent.Parent.HUD.SkillsHolder.Slot2.CooldownQ
local last = tick() - cooldown
if last > cooldown then last = cooldown end
local keyWordTable = {
	["AttackKey"] = Enum.KeyCode.E -- set this to your default key
}
Slot1.MouseButton1Click:Connect(function()
	keyWordTable["AttackKey"] = Enum.KeyCode.Q
end)
Slot2.MouseButton1Click:Connect(function()
	keyWordTable["AttackKey"] = Enum.KeyCode.E
end)

local guiWordTable = {
	["guikey"] = Skillslot1
}
Slot1.MouseButton1Click:Connect(function()
	guiWordTable["guikey"] = Skillslot1
end)
Slot2.MouseButton1Click:Connect(function()

	guiWordTable["guikey"] = Skillslot2
end)

UIS.InputBegan:Connect(function(Input,isTyping)
	if isTyping then
		return
	elseif Input.KeyCode == keyWordTable["AttackKey"] then
		if debounce == false and active == false then
			debounce = true
			
			Kameha:FireServer(active)
		end
	end
end)

UIS.InputEnded:Connect(function(Input,isTyping)
	if isTyping then
		return
	elseif Input.KeyCode == keyWordTable["AttackKey"] then
		if debounce == true and active == false then
			active = true
			guiWordTable["guikey"]:TweenSize(UDim2.new(1,0, 1, 0),"In","Linear", 0)
			Kameha:FireServer(active)
		end
	end
end)

Kameha.OnClientEvent:Connect(function()
	local change = 1 - (last/cooldown)
	guiWordTable["guikey"]:TweenSize(UDim2.new(1,0, change, 0),"In","Linear", cooldown)
	wait(cooldown)
	debounce = false
	active = false
end)

why did you delete your post?

Let’s take this step by step, I sometimes don’t wanna look at long code, but since you’ve been waiting a long time, why not.


Setup

  1. Have a table for moves. An example would be
local Moves = {
         ["ExampleMove"] = {["Activation1"]="Q",["Activation2"]="E",["ActivationFunction"]=function() print("activated") end}
}
  1. Make it so, whenever a player recieves a new skill, but they set Activation1 as one of their other skill’s keybinds, warn them about it, etc.
1 Like

Where would i put this?

In a “Manager” script.
From there, if you want to make individual scripts for the attacks, you have to make the “Manager” script a modulescript.
And then make methods that will allow the script to add a function into a table, that would add up to the “Setup” thing.

im kind of confused on how i would do this

I ended up thinking that error was the abilities being activated when clicked on the frame, so I deleted the post.