You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? A keybind system which works by communicating with modules that tell it the ability and its info
-
What is the issue? I can only use a keybind once. If i use Q, I wont be able to use any other keybind
-
What solutions have you tried so far? I have tried playing around with the modules but nothing has worked
here are my scripts
KeybindServer (module)
local keybinds = {
Witch = {
Pyrokinesis = {
SkillName = "Pyrokinesis",
Key = Enum.KeyCode.Q,
Cooldown = 6,
Anim = "rbxassetid://--placeholder"
},
Transmutation = {
SkillName = "Transmutation",
Key = Enum.KeyCode.E,
Cooldown = 8,
Anim = "rbxassetid://--placeholder"
},
Concilium = {
SkillName = "Transmutation",
Key = Enum.KeyCode.B,
Cooldown = 15,
Anim = "rbxassetid://--placeholder"
}
}
}
return keybinds
KeybindCheck (module)
local KeybindList = require(game.ServerScriptService.Modules.KeybindServer)
local KeybindCheck = {}
function KeybindCheck.Start(player, SkillName)
if player.Character:GetAttribute(SkillName.."Debounce") == false and (player.Character:GetAttribute("Disabled") == false) then
player.Character:SetAttribute("Disabled", true)
player.Character:SetAttribute("SkillName", SkillName)
player.Character:SetAttribute(SkillName.."Debounce", true)
return true
else
return false
end
end
function KeybindCheck.End(player, SkillName)
if player.Character:GetAttribute(SkillName.."Debounce") == true then
player.Character:SetAttribute("Disabled", false)
task.wait(KeybindList[player.Character:GetAttribute("Species")][SkillName].Cooldown)
player.Character:SetAttribute("SkillName", "")
player.Character:SetAttribute(SkillName.."Debounce", false)
end
end
return KeybindCheck
KeybindHandler (server script)
--Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
-- modules
local KeybindCheck = require(game.ServerScriptService.Modules.KeybindCheck)
-- global variables
local Event = ReplicatedStorage.WitchRemotes.Ability
local KeybindServer = game.ServerScriptService.Modules.KeybindServer
Event.OnServerEvent:Connect(function(player, SkillName, mousePosition, mouseTarget, plrCharacter)
if SkillName == "Pyrokinesis" then
if mouseTarget.Parent:FindFirstChild("Humanoid") then -- player
KeybindCheck.Start(player, SkillName)
local target = mouseTarget.Parent
local targetFire = ReplicatedStorage.WitchEffects.PlayerFire:Clone()
for i, v in pairs(targetFire:GetDescendants()) do
if v:IsA("ParticleEmitter") then
for i, p in pairs(target:GetDescendants()) do
if p:IsA("BasePart") or p:IsA("MeshPart") then
local effect = v:Clone()
effect.Parent = p
end
end
end
end
for i = 1,10 do
target.Humanoid:TakeDamage(4)
wait(0.3)
end
for i, v in pairs(target:GetDescendants()) do
if v:IsA("ParticleEmitter") and v.Name == "Fire" then
v.Enabled = false
end
end
wait(1)
for i, v in pairs(target:GetDescendants()) do
if v:IsA("ParticleEmitter") and v.Name == "Fire" then
v:Destroy()
end
end
KeybindCheck.End(player, SkillName)
elseif mouseTarget:FindFirstChild("CanBurn") then -- object
KeybindCheck.Start(player, SkillName)
local objectFire = ReplicatedStorage.WitchEffects.ObjectFire:Clone()
for i, v in pairs(objectFire:GetDescendants()) do
if v:IsA("ParticleEmitter") then
v.Parent = mouseTarget
end
end
wait(2)
local tween = TweenService:Create(mouseTarget, TweenInfo.new(1), {Transparency = 1})
tween:Play()
wait(0.25)
for i, v in pairs(mouseTarget:GetDescendants()) do
if v.Name == "Fire" then
v.Enabled = false
end
end
for i, v in pairs(mouseTarget:GetDescendants()) do
if v.Name == "Smoke" then
v.Enabled = true
end
end
wait(0.25)
for i, v in pairs(mouseTarget:GetDescendants()) do
if v.Name == "Smoke" then
v.Enabled = false
end
end
wait(0.75)
mouseTarget:Destroy()
KeybindCheck.End(player, SkillName)
end
end
if SkillName == "Transmutation" then -- this part is irrelevant, havent done anything here yet
for i, v in pairs(plrCharacter:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Decal") or v:IsA("Texture") then
local tween = TweenService:Create(v, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {Transparency = 1})
tween:Play()
end
end
wait(0.3)
local pos = mousePosition + Vector3.new(0,3,0)
plrCharacter:PivotTo(CFrame.new(pos))
wait()
for i, v in pairs(plrCharacter:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Decal") or v:IsA("Texture") then
if v.Name ~= "HumanoidRootPart" then
local tween = TweenService:Create(v, TweenInfo.new(0.5, Enum.EasingStyle.Quad), {Transparency = 0})
tween:Play()
end
end
end
end
if SkillName == "Concilium" then
end
end)
all help would be very appreciated