I have posted about this before, but no solutions work. I have a model attached to a player by motor6d which is a sword. Occasionally this sword randomly one shots.
This script is under every sword.
I’m not sure what’s going on.
'Ive used print statements and it says it runs once when the one shot occurs, so I don’t understand. Here’s most of the new script
local function stopSwing()
task.wait(.2)
swingCheck = false
debounce = false
damageCount = 0
end
script.Parent.SwordCombatRemote.OnServerEvent:Connect(function(player)
if swingCheck then return end
swingCheck = true
local character = player.Character
if character.IsRagdoll.Value then
swingCheck = false
return
end
local Hum = character:WaitForChild("Humanoid")
if Combo == 1 then
playAnim = Hum:LoadAnimation(anim)
playAnim:Play()
Combo = 2
elseif Combo == 2 then
playAnim = Hum:LoadAnimation(anim2)
playAnim:Play()
Combo = 1
end
task.wait(0.25)
sound:Play()
local physicalBox = Instance.new("Part", character)
physicalBox.Name = "Hitbox"
physicalBox.Transparency = 1
physicalBox.Anchored = false
physicalBox.CanCollide = false
physicalBox.Size = Vector3.new(5.5, 2.5, 5.5)
physicalBox.Massless = true
physicalBox.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -3.5)
physicalBox.Parent = character.HumanoidRootPart
local weld = Instance.new("WeldConstraint")
weld.Part0 = character.HumanoidRootPart
weld.Part1 = physicalBox
weld.Parent = character.HumanoidRootPart
game.Debris:AddItem(weld, 0.5)
game.Debris:AddItem(physicalBox, 0.5)
local affected = {}
local TouchEvent
task.wait()
TouchEvent = physicalBox.Touched:Connect(function(hit)
if debounce == true then
return
else
debounce = true
end
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if hit.Parent ~= character then
if character:FindFirstChild("IsRagdoll").Value == false then
if game.Players:GetPlayerFromCharacter(hit.Parent):WaitForChild("Bool").Invincible.Value == false then
if not table.find(affected, hit.Parent) then
table.insert(affected, hit.Parent)
if damageCount < 2 then
TouchEvent:Disconnect()
physicalBox:Destroy()
damageCount += 1
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(12)
swordRagdoll(hit.Parent, character)
local attacker = game.Players:GetPlayerFromCharacter(character)
if attacker and attacker:FindFirstChild("leaderstats") then
attacker.leaderstats.Hits.Value += 1
end
end
end
end
end
end
end
debounce = false
end)
playAnim.Stopped:Connect(stopSwing)
end)
Also, would idea to have a damage handler in serverscriptservice or not. Script above is sever script under model.