Hello for some reason does SharedAttackValues.isBeingAttacked[target] never stay there,…
- User
Hello for some reason does SharedAttackValues.isBeingAttacked[target] never stay there, it's just gone all the time: local require = require(script.Parent.loader).load(script) local ActionPipe = require("ActionPipe") local SharedAttackValues = require("SharedAttackValues")
local Promise = require("Promise")
local Players = game:GetService("Players") local remote = game:GetService("ReplicatedStorage"):WaitForChild("CombatEvent")
local function GetTouchingParts(part) local connection = part.Touched:Connect(function() end) local results = part:GetTouchingParts() connection:Disconnect() return results end
local function hitbox(size, cframe, ignore, char)
if(not workspace.Fx) then local fx = Instance.new("Folder", workspace) fx.Name = "Fx" end local hb = Instance.new("Part", workspace.Fx) hb.Anchored = true hb.CanCollide = false hb.Transparency = .6 hb.Size = size hb.Name = "Hitbox" hb.Material = Enum.Material.ForceField hb.CFrame = cframe hb.CanQuery = false local connection connection = hb.Touched:Connect(function() connection:Disconnect() end) local lastTarget for i,v in pairs(hb:GetTouchingParts()) do if v.Parent:FindFirstChild("Humanoid") and table.find(ignore, v.Parent) == nil then if lastTarget then if(lastTarget.Position - char.PrimaryPart.Position).Magnitude > (v.Position - char.PrimaryPart.Position).Magnitude then lastTarget = v.Parent.PrimaryPart end else lastTarget = v.Parent.PrimaryPart end end end hb:Destroy() if lastTarget then return lastTarget else return nil endend
return { args = { name = "AttackAction"; },
execute = function() remote.OnServerEvent:Connect(function(player, data) if SharedAttackValues.isTargetAttacked(data.Character) and tick() - SharedAttackValues.returnTick(data.Character) < 0.5 then return elseif SharedAttackValues.isTargetAttacked(data.Character) then SharedAttackValues.setValue(data.Character, nil) end if(SharedAttackValues.isBeingAttacked[data.Character]) then return end local actionPipe = ActionPipe.new() local bodyVelocity = Instance.new("BodyVelocity", data.Character.PrimaryPart) bodyVelocity.Velocity = data.Character.PrimaryPart.CFrame.LookVector * 25 bodyVelocity.MaxForce = Vector3.new(99999, 99999, 99999) bodyVelocity.Name = "Knockback" game.Debris:AddItem(bodyVelocity, .2) local hitTarget = hitbox(Vector3.new(6, 6, 6), data.Character.PrimaryPart.CFrame * CFrame.new(0,0,-3), {data.Character}, data.Character) if(hitTarget == nil) then return end if(Players:GetPlayerFromCharacter(hitTarget.Parent) ~= nil) then Players:GetPlayerFromCharacter(hitTarget.Parent):FindFirstChild("LastTarget").Value = tostring(data.Character) end SharedAttackValues.setValue(hitTarget.Parent, tick()) hitTarget.Parent.Humanoid.WalkSpeed = 0 SharedAttackValues.isBeingAttacked[hitTarget.Parent] = true print(tostring(hitTarget.Parent) .. " is being attacked") Promise.delay(.5, function() if(SharedAttackValues.returnTick(hitTarget.Parent) ~= nil) then print(tick() - SharedAttackValues.returnTick(hitTarget.Parent)) if tick() - SharedAttackValues.returnTick(hitTarget.Parent) > 0.5 then print(tostring(hitTarget.Parent) .. " is no longer being attacked") SharedAttackValues.isBeingAttacked[hitTarget.Parent] = false end end end) if data.Action == "m1" then if(data.Combo == 5) then hitTarget.Parent.Humanoid:TakeDamage(12) else hitTarget.Parent.Humanoid:TakeDamage(8) end end if(data.Combo == 5) then actionPipe.executeClientAction(player, "DragAction", data) local bodyVelocity = Instance.new("BodyVelocity", hitTarget) bodyVelocity.Velocity = data.Character.PrimaryPart.CFrame.LookVector * 75 bodyVelocity.MaxForce = Vector3.new(99999, 99999, 99999) bodyVelocity.Name = "Knockback" game.Debris:AddItem(bodyVelocity, .2) else local bodyVelocity = Instance.new("BodyVelocity", hitTarget) bodyVelocity.Velocity = data.Character.PrimaryPart.CFrame.LookVector * 25 bodyVelocity.MaxForce = Vector3.new(99999, 99999, 99999) bodyVelocity.Name = "Knockback" game.Debris:AddItem(bodyVelocity, .2) end task.wait(1) hitTarget.Parent.Humanoid.WalkSpeed = 10 end) end - Assistant
- User
Could you look in to the script for me and try to fix the issue and rewrite the script and what was wrong?
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.