
gpt, can you fix some parts of this script for me, its from ...
Prompt
gpt, can you fix some parts of this script for me, its from Lua, aka roblox studios coding, etc, i need you to make it so the vfx only appears if the attack hits someone, right now its always appearing even when i dont hit someone, also, if i use the attack too much, it litterally does not let me use it anymore, see if you could find a potential fix to this, and also improve the finisher effect(i think you may find it there), etc, theres also a local script, which i am sending after the script: local Tool = script.Parent local ReplicatedStorage = game:GetService("ReplicatedStorage") local TweenService = game:GetService("TweenService") local Debris = game:GetService("Debris") local Players = game:GetService("Players") -------------------------------------------------- -- SETTINGS & CONFIGURATION -------------------------------------------------- local BASE_DAMAGE = 28 local FINISHER_HEALTH = 20 local COOLDOWN = 2.2 local STUN_TIME = 0.8 local KNOCKBACK = 42 local SELF_STUN = 0.7 local ANIMATION_ID = "rbxassetid://117987254457171" -- Audio slots local AXE_SWING_SOUND_ID = "rbxassetid://101754068104110" local AXE_HIT_SOUND_ID = "rbxassetid://124606578932734" local BRUTALIZE_SOUND_ID = "" -- Optional extra sound for finishing a low-HP target -- Hitbox Settings local HITBOX_SIZE = Vector3.new(10, 8, 10) local HITBOX_OFFSET = Vector3.new(0, 0, -5) local HITBOX_SAMPLES = 4 local HITBOX_SAMPLE_INTERVAL = 0.04 local HIT_FAILSAFE_TIME = 0.33 -------------------------------------------------- -- REFERENCES -------------------------------------------------- local VFX = ReplicatedStorage:FindFirstChild("VFX") local VFX2 = ReplicatedStorage:FindFirstChild("VFX2") -- Fallback slash mesh search local SlashMesh = (VFX and (VFX:FindFirstChild("Beam2") or VFX:FindFirstChild("Beam1"))) or (VFX2 and (VFX2:FindFirstChild("Beam2") or VFX2:FindFirstChild("Beam1"))) local MeleeHitboxTemplate = (VFX2 and VFX2:FindFirstChild("MeleeHitbox")) or (VFX and VFX:FindFirstChild("MeleeHitbox")) local FXRemote = Tool:FindFirstChild("FXRemote") if not FXRemote then FXRemote = Instance.new("RemoteEvent") FXRemote.Name = "FXRemote" FXRemote.Parent = Tool end -------------------------------------------------- -- STATE -------------------------------------------------- local debounce = false local originalName = Tool.Name -------------------------------------------------- -- HELPERS -------------------------------------------------- local function getAnimator(humanoid) local animator = humanoid:FindFirstChildOfClass("Animator") if not animator then animator = Instance.new("Animator") animator.Parent = humanoid end return animator end local function addStun(character, duration) if not character then return end local stun = character:FindFirstChild("AttackStun") if not stun then stun = Instance.new("BoolValue") stun.Name = "AttackStun" stun.Parent = character end character:SetAttribute("IsStunned", true) Debris:AddItem(stun, duration) task.delay(duration, function() if character and character:FindFirstChild("AttackStun") == stun then character:SetAttribute("IsStunned", false) end end) end local function isStunned(character) return character:FindFirstChild("AttackStun") ~= nil or character:GetAttribute("IsStunned") == true end local function playSound(id, pos, volume, speed) if not id or id == "" or id == "rbxassetid://" then return end local p = Instance.new("Part") p.Transparency = 1 p.Anchored = true p.CanCollide = false p.CanTouch = false p.CanQuery = false p.Position = pos p.Parent = workspace local s = Instance.new("Sound") s.SoundId = id s.Volume = volume or 1 s.PlaybackSpeed = speed or 1 s.RollOffMaxDistance = 120 s.Parent = p s:Play() Debris:AddItem(p, 3) end local function markCleanup(inst) if _G.VFXCleanup and typeof(_G.VFXCleanup.Mark) == "function" then _G.VFXCleanup.Mark(inst) end end -------------------------------------------------- -- VISUAL EFFECTS -------------------------------------------------- local function createSlashVisual(cframe, lookVector) if SlashMesh and SlashMesh:IsA("BasePart") then local beam = SlashMesh:Clone() beam.Parent = workspace beam.Anchored = true beam.CanCollide = false beam.CanTouch = false beam.CanQuery = false beam.Material = Enum.Material.Neon beam.Color = Color3.fromRGB(220, 20, 20) local base = beam.Size beam.CFrame = cframe * CFrame.Angles(0, 0, math.rad(math.random(-25, 25))) beam.Size = Vector3.new(base.X * 0.2, base.Y * 2, base.Z * 0.2) local ghost = beam:Clone() ghost.Material = Enum.Material.ForceField ghost.Color = Color3.fromRGB(255, 60, 60) ghost.Transparency = 0.4 ghost.Parent = workspace local endCF = beam.CFrame * CFrame.Angles(0, 0, math.rad(35)) TweenService:Create(beam, TweenInfo.new(0.35, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Size = Vector3.new(base.X * 1.8, base.Y * 2.6, base.Z * 1.8), Transparency = 1, CFrame = endCF, }):Play() TweenService:Create(ghost, TweenInfo.new(0.35, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Size = Vector3.new(base.X * 2.5, base.Y * 3.2, base.Z * 2.5), Transparency = 1, CFrame = endCF * CFrame.Angles(0, 0, math.rad(-15)), }):Play() markCleanup(beam) markCleanup(ghost) Debris:AddItem(beam, 0.4) Debris:AddItem(ghost, 0.4) else -- Procedural slash fallback local slash = Instance.new("Part") slash.Material = Enum.Material.Neon slash.Color = Color3.fromRGB(255, 20, 20) slash.Transparency = 0.15 slash.Anchored = true slash.CanCollide = false slash.CanTouch = false slash.CanQuery = false slash.Size = Vector3.new(8, 10, 1) slash.CFrame = cframe * CFrame.Angles(0, 0, math.rad(math.random(-20, 20))) slash.Parent = workspace TweenService:Create(slash, TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Transparency = 1, Size = Vector3.new(18, 22, 1), }):Play() markCleanup(slash) Debris:AddItem(slash, 0.25) end end local function createBloodBurst(pos, heavy) local count = heavy and 24 or 12 for _ = 1, count do local blood = Instance.new("Part") blood.Shape = Enum.PartType.Ball blood.Material = Enum.Material.Neon blood.Color = Color3.fromRGB(math.random(110, 160), 0, 0) local size = math.random(10, 25) / 10 blood.Size = Vector3.new(size, size, size) blood.Position = pos blood.CanCollide = false blood.CanTouch = false blood.CanQuery = false blood.Parent = workspace local vel = Instance.new("BodyVelocity") vel.MaxForce = Vector3.new(999999, 999999, 999999) vel.Velocity = Vector3.new(math.random(-45, 45), math.random(15, 60), math.random(-45, 45)) vel.Parent = blood Debris:AddItem(vel, 0.12) TweenService:Create(blood, TweenInfo.new(0.65), { Transparency = 1 }):Play() Debris:AddItem(blood, 0.7) markCleanup(blood) end end local function createBloodPuddle(pos) local puddle = Instance.new("Part") puddle.Shape = Enum.PartType.Cylinder puddle.Material = Enum.Material.SmoothPlastic puddle.Color = Color3.fromRGB(math.random(80, 120), 0, 0) puddle.Transparency = math.random(20, 40) / 100 puddle.Anchored = true puddle.CanCollide = false puddle.CanTouch = false puddle.CanQuery = false local rSize = math.random(4, 7) puddle.Size = Vector3.new(0.1, rSize, rSize) puddle.CFrame = CFrame.new(pos - Vector3.new(0, 2.7, 0)) * CFrame.Angles(0, 0, math.rad(90)) puddle.Parent = workspace TweenService:Create(puddle, TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Size = Vector3.new(0.1, rSize + 2, rSize + 2), }):Play() Debris:AddItem(puddle, 8) markCleanup(puddle) end local function createGroundCrack(pos) for _ = 1, 6 do local crack = Instance.new("Part") crack.Material = Enum.Material.Slate crack.Color = Color3.fromRGB(35, 35, 35) crack.Anchored = true crack.CanCollide = false crack.CanTouch = false crack.CanQuery = false crack.Size = Vector3.new(math.random(2, 4), 0.15, math.random(1, 2)) crack.CFrame = CFrame.new(pos + Vector3.new(math.random(-3, 3), -2.6, math.random(-3, 3))) * CFrame.Angles(0, math.rad(math.random(0, 360)), 0) crack.Parent = workspace TweenService:Create(crack, TweenInfo.new(1.2), { Transparency = 1 }):Play() Debris:AddItem(crack, 1.3) markCleanup(crack) end end local function createImpact(pos) local shock = Instance.new("Part") shock.Shape = Enum.PartType.Ball shock.Material = Enum.Material.ForceField shock.Color = Color3.fromRGB(150, 0, 0) shock.Transparency = 0.3 shock.Anchored = true shock.CanCollide = false shock.CanTouch = false shock.CanQuery = false shock.Size = Vector3.new(2, 2, 2) shock.Position = pos shock.Parent = workspace TweenService:Create(shock, TweenInfo.new(0.22, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Size = Vector3.new(14, 14, 14), Transparency = 1, }):Play() Debris:AddItem(shock, 0.25) markCleanup(shock) end local function brutalize(character) local root = character:FindFirstChild("HumanoidRootPart") local hum = character:FindFirstChildOfClass("Humanoid") if root then playSound(BRUTALIZE_SOUND_ID, root.Position, 1.2, 0.9) createBloodBurst(root.Position, true) createImpact(root.Position) createGroundCrack(root.Position) for _ = 1, 4 do createBloodPuddle(root.Position + Vector3.new(math.random(-4, 4), 0, math.random(-4, 4))) end end for _, part in ipairs(character:GetDescendants()) do if part:IsA("BasePart") then part.Transparency = 1 part.CanCollide = false end end if hum then hum.Health = 0 end task.wait(0.1) if character and character.Parent then character:Destroy() end end -------------------------------------------------- -- HIT DETECTION -------------------------------------------------- local function getHitbox() local hitbox if MeleeHitboxTemplate and MeleeHitboxTemplate:IsA("BasePart") then hitbox = MeleeHitboxTemplate:Clone() else hitbox = Instance.new("Part") hitbox.Shape = Enum.PartType.Ball end hitbox.Name = "AxeSlashHitbox" hitbox.Size = HITBOX_SIZE hitbox.Transparency = 1 hitbox.Anchored = true hitbox.CanCollide = false hitbox.CanTouch = false hitbox.CanQuery = true hitbox.CastShadow = false hitbox.Massless = true hitbox.Parent = workspace return hitbox end local function performHit(attackerCharacter, playerOwner) local root = attackerCharacter:FindFirstChild("HumanoidRootPart") if not root then return end local multiplier = attackerCharacter:GetAttribute("RageMultiplier") or 1 local calculatedDamage = BASE_DAMAGE * multiplier local hitOrigin = root.CFrame * CFrame.new(HITBOX_OFFSET) createSlashVisual(hitOrigin, root.CFrame.LookVector) createImpact(hitOrigin.Position) local alreadyHit = {} local hitAny = false for sample = 1, HITBOX_SAMPLES do if not root.Parent then break end local currentCF = root.CFrame * CFrame.new(HITBOX_OFFSET) local hitbox = getHitbox() hitbox.CFrame = currentCF local parts = workspace:GetPartsInPart(hitbox) hitbox:Destroy() for _, part in ipairs(parts) do local model = part:FindFirstAncestorOfClass("Model") if model and model ~= attackerCharacter and not alreadyHit[model] then local enemyHum = model:FindFirstChildOfClass("Humanoid") local enemyRoot = model:FindFirstChild("HumanoidRootPart") if enemyHum and enemyRoot and enemyHum.Health > 0 then alreadyHit[model] = true hitAny = true playSound(AXE_HIT_SOUND_ID, enemyRoot.Position, 1, math.random(95, 105) / 100) createBloodBurst(enemyRoot.Position, false) createGroundCrack(enemyRoot.Position) createBloodPuddle(enemyRoot.Position) if enemyHum.Health <= FINISHER_HEALTH then brutalize(model) else enemyHum:TakeDamage(calculatedDamage) addStun(model, STUN_TIME) local vel = Instance.new("BodyVelocity") vel.MaxForce = Vector3.new(999999, 999999, 999999) vel.Velocity = (root.CFrame.LookVector * KNOCKBACK) + Vector3.new(0, 10, 0) vel.Parent = enemyRoot Debris:AddItem(vel, 0.15) end end end end task.wait(HITBOX_SAMPLE_INTERVAL) end if playerOwner then FXRemote:FireClient(playerOwner, hitAny) end end -------------------------------------------------- -- COOLDOWN DISPLAY -------------------------------------------------- local function startCooldown() task.spawn(function() local started = os.clock() while Tool.Parent and (os.clock() - started) < COOLDOWN do local remaining = COOLDOWN - (os.clock() - started) Tool.Name = ("Axe Slash [%.1f]"):format(math.max(remaining, 0)) task.wait(0.1) end if Tool.Parent then Tool.Name = originalName end debounce = false end) end -------------------------------------------------- -- TOOL ACTIVATION -------------------------------------------------- Tool.Activated:Connect(function() if debounce then return end local character = Tool.Parent if not character or not character:IsA("Model") or isStunned(character) then return end local humanoid = character:FindFirstChildOfClass("Humanoid") local root = character:FindFirstChild("HumanoidRootPart") if not humanoid or not root or humanoid.Health <= 0 then return end local playerOwner = Players:GetPlayerFromCharacter(character) debounce = true addStun(character, SELF_STUN) local animator = getAnimator(humanoid) local animation = Instance.new("Animation") animation.AnimationId = ANIMATION_ID local track = animator:LoadAnimation(animation) track.Priority = Enum.AnimationPriority.Action track.Looped = false track:Play() playSound(AXE_SWING_SOUND_ID, root.Position, 0.9, 1) local hitExecuted = false local hitConnection local function execute() if hitExecuted then return end hitExecuted = true if hitConnection then hitConnection:Disconnect() hitConnection = nil end performHit(character, playerOwner) end hitConnection = track:GetMarkerReachedSignal("Hit"):Connect(execute) -- Failsafe in case marker was not placed on the animation task.delay(HIT_FAILSAFE_TIME, execute) startCooldown() end)