JIT
enhancing your code with additional moves and abilities
this code. local Tool = script.Parent local Remote = Tool:FindFirstChild("Remote") or Instance.new("RemoteEvent", Tool) Tool.Enabled = true local Debris = game:GetService("Debris") local Sounds = script.Parent:WaitForChild("Audio") local handle = Tool:FindFirstChild("Handle") -- Helper to play a sound (cloned so overlapping plays work) local function playSound(soundName, parent) local snd = Sounds:FindFirstChild(soundName) if snd then local soundClone = snd:Clone() soundClone.Parent = parent or Tool soundClone:Play() soundClone.Ended:Connect(function() soundClone:Destroy() end) return soundClone end end -- Equip and unequip behavior Tool.Equipped:Connect(function() playSound("Equip", Sounds) local music = Sounds:FindFirstChild("Music") if music then music.Looped = true music:Play() end end) Tool.Unequipped:Connect(function() local music = Sounds:FindFirstChild("Music") if music then music:Stop() end end) -- Generic projectile creation function with damage on touch local function createProjectile(params) -- params: name, size, shape, color, material, position, velocity, damage, lifetime local proj = Instance.new("Part") proj.Name = params.name proj.Size = params.size proj.Shape = params.shape or Enum.PartType.Block proj.BrickColor = BrickColor.new(params.color) proj.Material = params.material or Enum.Material.Neon proj.CanCollide = false proj.Anchored = false proj.Massless = false proj.Position = params.position proj.Parent = workspace local bv = Instance.new("BodyVelocity", proj) bv.MaxForce = Vector3.new(1e5, 1e5, 1e5) bv.Velocity = params.velocity proj.Touched:Connect(function(hit) local character = hit.Parent local humanoid = character and character:FindFirstChild("Humanoid") if humanoid and hit:IsDescendantOf(character) then humanoid:TakeDamage(params.damage) proj:Destroy() end end) Debris:AddItem(proj, params.lifetime or 5) return proj end -- Abilities reworked into functions local Abilities = { Ability1 = function(player) playSound("SpellMiniCharge", Sounds) wait(0.75) local shots, fireballCount = 3, 5 for s = 1, shots do for i = 1, fireballCount do local pos = player.Character.HumanoidRootPart.Position + player.Character.HumanoidRootPart.CFrame.LookVector * 7.5 -- random spread vector local spread = Vector3.new( (math.random() * 10 - 5) / 2.5, (math.random() * 10 - 5) / 3, (math.random() * 10 - 5) ) local velocity = player.Character.HumanoidRootPart.CFrame.LookVector * 50 + spread playSound("Spell", Sounds) playSound("BigShot", Sounds) createProjectile({ name = "Fireball", size = Vector3.new(2.5, 2.5, 2.5), shape = Enum.PartType.Ball, color = "Neon orange", position = pos, velocity = velocity, damage = 5, lifetime = 5 }) end wait(0.75) end playSound("SpellDisappear", Sounds) end, Ability2 = function(player) playSound("SpellCharge", Sounds) wait(1) local shots, count = 3, 5 for s = 1, shots do local angleStep = 25 / (count - 3) for i = 0, count - 1 do local pos = player.Character.HumanoidRootPart.Position + player.Character.HumanoidRootPart.CFrame.LookVector * 10 local angleOffset = (i - (count - 1) / 2) * angleStep local velocity = player.Character.HumanoidRootPart.CFrame.LookVector * 13.5 + player.Character.HumanoidRootPart.CFrame.RightVector * angleOffset playSound("Spell", Sounds) playSound("BigShot", Sounds) playSound("StrongerSpell", Sounds) createProjectile({ name = "PillarFire", size = Vector3.new(2, 50, 2), shape = Enum.PartType.Block, color = "Daisy orange", position = pos, velocity = velocity, damage = 15, lifetime = 10 }) end wait(1.25) end playSound("SpellDisappear", Sounds) end, Ability3 = function(player) playSound("SpellCharge", Sounds) wait(1) local meteorCount = 10 local distance = 65 for i = 1, meteorCount do local pos = player.Character.HumanoidRootPart.Position + Vector3.new(0, 200, 0) + player.Character.HumanoidRootPart.CFrame.LookVector * (i * distance) playSound("Spell", Sounds) playSound("SpellTwinkle", Sounds) createProjectile({ name = "BigShot", size = Vector3.new(45, 45, 45), shape = Enum.PartType.Ball, color = "Neon orange", position = pos, velocity = Vector3.new(0, -65, 0), damage = 50, lifetime = 10 }) wait(0.2) end wait(1) playSound("SpellDisappear", Sounds) end, Ability4 = function(player) playSound("SpellBigCharge", Sounds) wait(3.5) for batch = 1, 5 do for i = 1, 10 do local randomPos = Vector3.new( math.random(-350, 350), math.random(750, 1000), math.random(-350, 350) ) local pos = player.Character.HumanoidRootPart.Position + randomPos playSound("Spell", Sounds) playSound("BigShot", Sounds) playSound("MegaMeteorAlert", Sounds) createProjectile({ name = "BigShot", size = Vector3.new(90, 90, 90), shape = Enum.PartType.Ball, color = "Really red", position = pos, velocity = Vector3.new(0, -50, 0), damage = 75, lifetime = 15 }) end wait(4) end wait(1) playSound("SpellDisappear", Sounds) end } local function TriggerAbility(player, ability) if Abilities[ability] then Abilities[ability](player) end end Remote.OnServerEvent:Connect(function(player, ability) TriggerAbility(player, ability) end) -- SunPowerUpdate event for playing full charge sound local SunPowerUpdate = Instance.new("RemoteEvent") SunPowerUpdate.Name = "SunPowerUpdate" SunPowerUpdate.Parent = Tool SunPowerUpdate.OnServerEvent:Connect(function(player, newSunPowerPoints) if newSunPowerPoints > 0 then playSound("FullCharge", handle) end end) -- Charge sound handling and particle toggling local ChargeSounds = { ChargeStart = Sounds:WaitForChild("Chargeup"), ChargeHeld = Sounds:WaitForChild("ChargeHold") } local chargeHeldSoundPlaying = false local function toggleParticles(enabled) local parts = handle.StarPartics local ct = parts:FindFirstChild("ChargeTwinkle") local t = parts:FindFirstChild("Twinkle") local pt = parts:FindFirstChild("ParticleTwinkle") local cpt = parts:FindFirstChild("ChargeParticleTwinkle") if ct and t and pt and cpt then ct.Enabled = enabled t.Enabled = not enabled cpt.Enabled = enabled pt.Enabled = not enabled end end Remote.OnServerEvent:Connect(function(player, eventName) if eventName == "ChargeStart" then local sound = ChargeSounds.ChargeStart:Clone() sound.Parent = handle sound:Play() sound.Ended:Connect(function() sound:Destroy() end) toggleParticles(false) elseif eventName == "ChargeHeld" and not chargeHeldSoundPlaying then chargeHeldSoundPlaying = true local sound = ChargeSounds.ChargeHeld:Clone() sound.Parent = handle sound:Play() sound.Ended:Connect(function() sound:Destroy() chargeHeldSoundPlaying = false end) toggleParticles(true) elseif eventName == "ChargeStop" then local sound = Sounds:WaitForChild("ChargeStop"):Clone() sound.Parent = handle sound:Play() sound.Ended:Connect(function() sound:Destroy() end) toggleParticles(false) end end) and this local code. local Tool = script.Parent local Remote = Tool:WaitForChild("Remote", 10) local SunPowerUpdate = Tool:FindFirstChild("SunPowerUpdate") or Instance.new("RemoteEvent", Tool) SunPowerUpdate.Name = "SunPowerUpdate" local Players = game:GetService("Players") local InputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local Player, Character, Humanoid local SunPowerPoints = 0 local Charging = false local ChargeStartTime, ChargeCooldownTimer = nil, 0 local ChargeDuration, ChargeCooldown = 1.5, 1.75 local MaxSunPowerPoints = 25 local toolEquipped = false local abilityData = { Ability1 = { cost = 1, cooldown = 4 }, Ability2 = { cost = 2, cooldown = 6 }, Ability3 = { cost = 4, cooldown = 8 }, Ability4 = { cost = 10, cooldown = 30 }, } local abilityCooldowns = {} -- Stores cooldown expiry times for abilities local SunPowerLabel, ScreenGui local function TriggerAbility(ability) local data = abilityData[ability] if not data then return end if SunPowerPoints < data.cost then print("Not enough SunPowerPoints to use " .. ability) return end if abilityCooldowns[ability] and tick() < abilityCooldowns[ability] then return end Remote:FireServer(ability) SunPowerPoints = SunPowerPoints - data.cost abilityCooldowns[ability] = tick() + data.cooldown end Remote.OnClientEvent:Connect(function(event) -- Handle server feedback here if needed end) local function StartCharging() if not Charging and SunPowerPoints < MaxSunPowerPoints and ChargeCooldownTimer <= 0 then Charging = true ChargeStartTime = tick() Remote:FireServer("ChargeStart") end end local function StopCharging() if Charging then Charging = false ChargeStartTime = nil Remote:FireServer("ChargeStop") ChargeCooldownTimer = ChargeCooldown end end local function UpdateCharging(dt) if Charging then Remote:FireServer("ChargeHeld") if tick() - ChargeStartTime >= ChargeDuration then if SunPowerPoints < MaxSunPowerPoints then SunPowerPoints = SunPowerPoints + 1 ChargeStartTime = tick() SunPowerUpdate:FireServer(SunPowerPoints) end end end if ChargeCooldownTimer > 0 then ChargeCooldownTimer = math.max(ChargeCooldownTimer - dt, 0) end end local function CreateHud() local player = Players.LocalPlayer ScreenGui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui")) ScreenGui.Name = "SunPowerHud" SunPowerLabel = Instance.new("TextLabel", ScreenGui) SunPowerLabel.Size = UDim2.new(0, 200, 0, 50) SunPowerLabel.Position = UDim2.new(0.5, -100, 0, 20) SunPowerLabel.BackgroundTransparency = 0.5 SunPowerLabel.BackgroundColor3 = Color3.new(0, 0, 0) SunPowerLabel.TextColor3 = Color3.new(1, 1, 1) SunPowerLabel.TextSize = 24 SunPowerLabel.Text = "SunPower: " .. SunPowerPoints end local function Equipped() Player = Players.LocalPlayer Character = Player.Character or Player.CharacterAdded:Wait() Humanoid = Character:FindFirstChildOfClass("Humanoid") if not Humanoid or Humanoid.Health <= 0 then return end toolEquipped = true CreateHud() -- Listen for key inputs InputService.InputBegan:Connect(function(input, gameProcessed) if gameProcessed or not toolEquipped then return end if input.KeyCode == Enum.KeyCode.Q then StartCharging() elseif input.KeyCode == Enum.KeyCode.E then TriggerAbility("Ability1") elseif input.KeyCode == Enum.KeyCode.R then TriggerAbility("Ability2") elseif input.KeyCode == Enum.KeyCode.T then TriggerAbility("Ability3") elseif input.KeyCode == Enum.KeyCode.F then TriggerAbility("Ability4") end end) InputService.InputEnded:Connect(function(input) if toolEquipped and input.KeyCode == Enum.KeyCode.Q then StopCharging() end end) -- Update HUD and charging continuously RunService.Heartbeat:Connect(function(dt) if SunPowerLabel then SunPowerLabel.Text = "SunPower: " .. SunPowerPoints end UpdateCharging(dt) end) end local function Unequipped() toolEquipped = false if ScreenGui then ScreenGui:Destroy() ScreenGui = nil end end Tool.Equipped:Connect(Equipped) Tool.Unequipped:Connect(Unequipped) make it that they have 10+ moves.
Updated files
v1