What is your issues?
My script is giving out ‘argument 1 missing nil’ error, and I don’t know the reason. However, the error starts on line 95. The script works fine otherwise. Basically, it checks if the module exists in the folder. If it doesn’t, it makes the specific UI invisible. But it’s not working as intended
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local sendkey = ReplicatedStorage.Remotes:WaitForChild("SendKeys")
local getchar = ReplicatedStorage.Remotes:WaitForChild("GetChar")
local bindFunction = ReplicatedStorage.Remotes:WaitForChild("BindFunction")
local skillsUtils = ReplicatedStorage:WaitForChild("SkillUtils")
local charData = skillsUtils:WaitForChild("CharacterData")
local debounces = {}
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:SetAttribute("Character", "None")
character:SetAttribute("Awakening", 0)
character.Parent = workspace.Entities
end)
player.CharacterRemoving:Connect(function()
debounces[player] = nil
end)
end)
sendkey.OnServerEvent:Connect(function(player, input)
local character = player.Character or player.CharacterAdded:Wait()
local selected = character:GetAttribute("Character")
if debounces[player] and debounces[player][input] then return end
debounces[player] = debounces[player] or {}
debounces[player][input] = true
local hotbox = player.PlayerGui:WaitForChild("Hotbox")
for _, child in pairs(charData:GetChildren()) do
if selected == child.Name then
local requireChar = require(child)
for _, abilityData in pairs(requireChar) do
if selected and input then
local characterFolder = script:FindFirstChild(selected)
if characterFolder then
local ability = characterFolder:FindFirstChild(input)
if ability and abilityData.Key == input then
local abilityInstance = require(ability).new(player)
local cooldown = hotbox:WaitForChild(input).Cooldown
if cooldown and not cooldown.Visible then
local startSize = cooldown.Size
local endSize = UDim2.new(0, 70, 0, -0)
cooldown.Size = UDim2.new(0, 70.8, 0, 70)
cooldown.Visible = true
local tweenInfo = TweenInfo.new(abilityData.Cooldown, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local tween = TweenService:Create(cooldown, tweenInfo, { Size = endSize })
tween:Play()
abilityInstance:Play()
tween.Completed:Wait()
local resetTween = TweenService:Create(cooldown, tweenInfo, { Size = startSize })
resetTween:Play()
cooldown.Visible = false
end
end
end
end
end
end
end
debounces[player][input] = nil
end)
getchar.OnServerEvent:Connect(function(player, name)
local hotbox = player.PlayerGui:WaitForChild("Hotbox")
local bar = player.PlayerGui:WaitForChild("AwakeningBar")
local character = player.Character or player.CharacterAdded:Wait()
if not character then
warn("Character not found for player:", player.Name)
return
end
if character.Humanoid.Health == 100 then
local character_Attribute = character:GetAttribute("Character")
character:SetAttribute("Character", name)
local characterFolder = script:FindFirstChild(name)
local availableModules = {}
for _, child in pairs(characterFolder:GetChildren()) do
if child:IsA("ModuleScript") then
table.insert(availableModules, child.Name)
end
end
for _, child in pairs(charData:GetChildren()) do
if child:IsA("ModuleScript") and child.Name == name then
local requireChar = require(child)
for _, abilityData in pairs(requireChar) do
local hotboxChar = hotbox:FindFirstChild(abilityData.Key) -- BUG
hotboxChar.SkillName.Text = abilityData.Name
if requireChar["Awakening"] then
local Charbar = bar:WaitForChild("Awakening")
Charbar.Text = requireChar["Awakening"]
Charbar.TextLabel.Text = requireChar["Awakening"]
end
end
end
end
bindFunction:InvokeClient(player, availableModules)
end
end)
Client –
local rp = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local hotbox = player:WaitForChild("PlayerGui"):WaitForChild("Hotbox")
local sendkey = rp.Remotes:WaitForChild("SendKeys")
local bindFunction = rp.Remotes:WaitForChild("BindFunction")
uis.InputBegan:Connect(function(input, processed)
if processed then return end
local char = player.Character or player.CharacterAdded:Wait()
if not char then return end
for _, v in pairs(hotbox:GetChildren()) do
if v:IsA("Frame") then
if input.KeyCode == Enum.KeyCode[v.Name] then
sendkey:FireServer(v.Name)
end
end
end
end)
bindFunction.OnClientInvoke = function(availableModules)
for _, v in pairs(hotbox:GetChildren()) do
if v:IsA("Frame") then
v.Visible = table.find(availableModules, v.Name) ~= nil
end
end
local spacing = 10
local totalWidth = 0
local visibleButtons = {}
for _, v in pairs(hotbox:GetChildren()) do
if v:IsA("Frame") then
totalWidth = totalWidth + v.Size.X.Offset + spacing
table.insert(visibleButtons,1,v)
end
end
totalWidth = totalWidth - spacing
local hotboxWidth = hotbox.AbsoluteSize.X
local startX = (hotboxWidth - totalWidth) / 2.05
for _, v in pairs(visibleButtons) do
v.Position = UDim2.new(0, startX, v.Position.Y.Scale, v.Position.Y.Offset)
startX = startX + v.Size.X.Offset + spacing
end
end
Module :
local module = {
{Key = "One", Name = "Blood Shard", Cooldown = 1};
{Key = "Two", Name = "Slicing Exorcism", Cooldown = 3};
{Key = "Three", Name = "Piercing Blood", Cooldown = 5};
["Awakening"] = "Big BROTHER!"
}