[localScript]
local player = game.Players.LocalPlayer
local UserInputType = game:GetService("UserInputService")
local Damage = script:WaitForChild("Damage")
local ComboCount = script:WaitForChild("ComboCount")
local IsCreated = script:WaitForChild("IsCreated")
local IsClicked = script:WaitForChild("IsClicked")
function FightControlls(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 and IsClicked.Value == false then
ComboCount.Value = ComboCount.Value + 1
IsClicked.Value = true
local HitDetector = player.Character:FindFirstChild("HitDetection")
if not HitDetector then
IsCreated.Value = true
print("HitDetector not created")
elseif HitDetector then
IsCreated.Value = true
print("hitdetector is created")
end
game.ReplicatedStorage.FightEvent:FireServer(Damage,ComboCount,IsClicked,IsCreated)
end
end
UserInputType.InputBegan:Connect(FightControlls)
[ServerScript]
game.ReplicatedStorage.FightEvent.OnServerEvent:Connect(function(player,Damage,
ComboCount,IsClicked,IsCreated)
if IsCreated.Value == true then
DetectionModel = game.ReplicatedStorage.HitDetection:Clone()
DetectionModel.Parent = player.Character.Head
local Weld = Instance.new("Weld")
Weld.Part0 = DetectionModel.MainHolder
Weld.Part1 = player.Character.Head
Weld.Parent = player.Character.Head
end
DetectionModel.Detector.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local Defense = hit.Parent:FindFirstChild("Defense")
local punched = humanoid:LoadAnimation(script.Fighting.Punched0)
print(IsClicked.Value)
if humanoid and IsClicked.Value == true and not Defense then
punched:Play()
humanoid:TakeDamage(Damage.Value)
punched:Stop()
IsClicked.Value = false
print(IsClicked.Value)
end
end)
end)
**** OUTPUT
15:17:50.023 - ScriptRoom.rbxl was auto-saved HitDetector not created 15:18:07.082 - ServerScriptService.CombatSystemV3:4: attempt to index local 'IsCreated' (a nil value) 15:18:07.084 - Stack Begin 15:18:07.085 - Script 'ServerScriptService.CombatSystemV3', Line 4 15:18:07.086 - Stack End

1 comment
Please healp