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)