Good Evening, fellow Developers! I'm coding for the first time (Attempting to Code a Battleground Game and I'm honestly stuck and confused where I went wrong. I followed along with a video I'll send in the description very closely to get ideas of how to begin coding.
Data Handler
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
for _, v in script.PlayerValues:GetChildren() do
v:Clone().Parent = Player
end
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage.Events
local AttackHitboxes = require(script.Parent.AttackHitboxes)
local ClickAttackDebounces = {}
Events.ClickAttack.OnServerEvent:Connect(function(Player)
local Character = Player.Character
if Character == nil then
return
end
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid == nil then
return
end
if Humanoid.Health > 0 then
end
end)
Server Attack Handler
local Humanoid = Character:FindFirstChild("Humanoid")
if not Humanoid then return end
if Humanoid.Health <= 0 then return end
if ClickAttackDebounces[Player] then return end
ClickAttackDebounces[Player] = true
local PunchCombo = Player.Value.PunchCombo
local Animation = script.PunchAnimationCycles:FindFirstChild(tostring(PunchCombo.Value))
if not Animation then
ClickAttackDebounces[Player] = nil
return
end
local Animator = Humanoid:FindFirstChild("Animator")
if not Animator then
ClickAttackDebounces[Player] = nil
return
end
local LoadedPunchAnimation = Animator:LoadAnimation(Animation)
LoadedPunchAnimation:Play()
if PunchCombo.Value >= #script.PunchAnimationCycles:GetChildren() then
PunchCombo.Value = 1
else
PunchCombo.Value += 1
end
task.wait(LoadedPunchAnimation.Length + 0.1)
ClickAttackDebounces[Player] = nil
end)
** You are now Level 1! **