I’m to make a stick pvp game, and it is working so far. However, I pull a weird error in the stick script that does not actually break it, I just can’t figure out how to fix it.
The issue is when I use the script the console saus “Table Index Is Nil”"
-- The Script
local debounce = false
script.Parent.Parent.Activated:Connect(function()
if debounce == false then
debounce = true
local anim = script.Parent.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Animation)
anim:Play()
wait(1)
debounce = false
end
end)
local PlayersHit = {}
script.Parent.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= script.Parent.Parent then
if debounce == true and PlayersHit[Hit.Parent] == nil then
Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(16)
debounce = true
Hit.Parent.Head.BillboardGui.Enabled = true
Hit.Parent.Head.BillboardGui.TextLabel.Text = "- 16"
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent)
if Hit.Parent.Humanoid.Health <= 0 then
player.leaderstats.Kills.Value += 1 * player.leaderstats.Multiplier.Value
end
script["Punch Kit Beefy Hit 1 (SFX)"]:Play()
PlayersHit[Hit.Parent] = true
wait(1)
PlayersHit[Hit.Parent] = nil
Hit.Parent.Head.BillboardGui.Enabled = false
end
end
end)
script.Parent.Parent.Equipped:Connect(function()
local player = script.Parent.Parent.Parent
player:WaitForChild("Humanoid").WalkSpeed = 22
end)
script.Parent.Parent.Unequipped:Connect(function()
local player = script.Parent.Parent.Parent.Parent
player.Character.Humanoid.WalkSpeed = 16
end)
script.Parent.Parent.Destroying:Connect(function()
local s, e = pcall(function()
script.Parent.Parent.Parent.Humanoid.WalkSpeed = 16
end)
if e then
elseif s then
end
local ss, ee = pcall(function()
script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 16
end)
if ee then
elseif ss then
end
end)
This only happens when I kill the dummmies I have set up, which have fully functional humanoids and everything. As for the weird table in the script, I don’t remember exactly what I was doing… but it works?
Does anyone know how to fix this? It would be really helpful!