So my script is very near to perfect, but there is one problem… I’ve made it so when the remote event fires
an attribute called “DamageEnabled” will become true and if rightArm is touched when damage enabled = true then the humanoid that touched it will lose health and damage enabled will be false, but when they click the right mouse button damage is enabled until they touch a player meaning they now dont have to “punch” and instead just walk into a player to damage them
2 Likes
Maybe you could add a wait() after enabling the damage and after that wait time has passed you disable it. If this doesn’t work, it would be helpful if you could provide the code.
1 Like
game.ReplicatedStorage.RemoteEvents.CombatEvent.OnServerEvent:Connect(function(plr, eventtype)
local CanDmg = true
local char = plr.Character
char:SetAttribute("Attacking", true)
char:SetAttribute("DamageEnabled", false)
local hum = char:FindFirstChild("Humanoid")
local hrp = char:FindFirstChild("HumanoidRootPart")
local p1
local p2
local db = game:GetService("Debris")
local rightArm = char["Right Arm"]
local leftArm = char["Left Arm"]
local HB = game.ReplicatedStorage.betterHB
local function changeAttribute(attribute, object, value)
wait(0.85)
object:SetAttribute(attribute, value)
end
local changeAtt = coroutine.create(changeAttribute)
if eventtype == "m1" then
coroutine.resume(changeAtt, "Attacking",char, false)
rightArm.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent:FindFirstChild("Humanoid") ~= hum then
if char:GetAttribute("DamageEnabled") == true then
char:SetAttribute("DamageEnabled", false)
if hit.Parent:GetAttribute("Parrying") == true then
elseif hit.Parent:GetAttribute("Blocking") == true and hit.Parent:GetAttribute("Parrying") ~= true then
elseif hit.Parent:GetAttribute("Blocking") ~= true and hit.Parent:GetAttribute("Parrying") ~= true then
hit.Parent:FindFirstChild("Humanoid").Health -= 3 * char:GetAttribute("DamageMultiplier")
end
end
end
end
end)
elseif eventtype == "m2" then
coroutine.resume(changeAtt, "Attacking", char, false)
leftArm.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent:FindFirstChild("Humanoid") ~= hum then
if char:GetAttribute("DamageEnabled") == true then
char:SetAttribute("DamageEnabled", false)
if hit.Parent:GetAttribute("Parrying") == true then
elseif hit.Parent:GetAttribute("Blocking") == true and hit.Parent:GetAttribute("Parrying") ~= true then
elseif hit.Parent:GetAttribute("Blocking") ~= true and hit.Parent:GetAttribute("Parrying") ~= true then
hit.Parent:FindFirstChild("Humanoid").Health -= 3 * char:GetAttribute("DamageMultiplier")
end
end
end
end
end)
elseif eventtype == "m3" then
coroutine.resume(changeAtt, "Attacking", char, false)
hrp.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent:FindFirstChild("Humanoid") ~= hum then
if char:GetAttribute("DamageEnabled") == true then
char:SetAttribute("DamageEnabled", false)
if hit.Parent:GetAttribute("Parrying") == true then
elseif hit.Parent:GetAttribute("Blocking") == true and hit.Parent:GetAttribute("Parrying") ~= true then
elseif hit.Parent:GetAttribute("Blocking") ~= true and hit.Parent:GetAttribute("Parrying") ~= true then
hit.Parent:FindFirstChild("Humanoid").Health -= 3 * char:GetAttribute("DamageMultiplier")
end
end
end
end
end)
end
end)
Maybe try adding this adding this to the changeAttribute function
object:SetAttribuite(attribute, value) --don't add this, this is just a reference
if attribute == "DamageEnabled" and value == "true" then
wait(x) --However long you want the damage to be enabled
object:SetAttribuite(attribute, not value)
end
This should effectively disable the damage after a certain amount of time. I believe it will work but i can’t promise anything.
1 Like