I have no clue what I am doing. I have tried tutorials online and even asking chatgpt to no avail. This is my first time ever coding in Luau and i am trying my very best to do great. here is my code
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local debris = game:GetService("Debris")
local move1Event = ReplicatedStorage:FindFirstChild("Actions"):WaitForChild("M1Event")
move1Event.OnServerEvent:Connect(function(player)
local char = player.Character
local humanoid = char:WaitForChild("Humanoid")
local hrp = char:FindFirstChild("HumanoidRootPart")
local arm = char:FindFirstChild("Right Arm")
humanoid.WalkSpeed = 0
local animFolder = ReplicatedStorage:FindFirstChild("Animation")
local anim = animFolder:FindFirstChild("Punch")
local track = humanoid:FindFirstChild("Animator"):LoadAnimation(anim)
track:Play()
--Visual Effect---\
--[[]]
local vfx1 = game.Workspace:FindFirstChild("Attack1VFX"):Clone() --Copy of VFX duh
vfx1.Anchored = true
vfx1.CanCollide = false
vfx1.CFrame = arm.CFrame*CFrame.new(0,0,-4) --Copies position and orientation from arm to VFX
print("CFrame Copied.")
vfx1.Parent = workspace
--]]
--Welding:
--[[
local weld = Instance.new("Weld")
weld.Part0 = arm
weld.Part1 = vfx1
weld.Parent = vfx1
weld.C0 = CFrame.new(0,0,-4)
--]]
--Visual Effect---/
debris:AddItem(vfx1,3)
--HitBox---\
--
local hitbox = game.Workspace:WaitForChild("Attack1Hitbox")
hitbox.Transparency = 1
hitbox.Anchored = true
hitbox.CanCollide = false
hitbox.CFrame = hrp.CFrame*CFrame.new(0,0,-4)
hitbox.Parent = workspace
--When Hitbox hits something:
local hitonce = {}
local amounta = 0
hitbox.Touched:Connect(function(hit)
amounta += 1
local enemychar = hit:FindFirstAncestorOfClass("Model")
if not enemychar then return end
print("almost hit", hitonce[1], enemychar)
local ehumanoid = enemychar.FindFirstChildOfClass("Humanoid")
if not ehumanoid then return end
if enemychar == "C" then
print("thats a mee!")
return
end
if hitonce[ehumanoid] then
print("neega i told you so")
return
end
print("it fail :(")
local enemyhrp = enemychar:FindFirstChild("HumanoidRootPart")
hitonce[ehumanoid] = true
ehumanoid:TakeDamage(10)
end)
print(amounta, "That much gaddam!")
--]]
--HitBox---/
--Ending---\
--debris:AddItem(hitbox)
humanoid.WalkSpeed = 16
--Ending---/
end)
I have included the entire script as I don't know what could be an issue and what wont be.
So far what happens is the code will run normally until I die, which causes the touched function to run multiple times for each part that it touches. It looks like it might be dependent on how quickly i spammed my move1Event.
** You are now Level 1! **