Help fix the script

Hello, I created a script to create an energy punch and I have problems 2 1.my numbers look orange 2.when I got for example 100m of power and this is the last ball and I then went did 101m of power and I have a ball becomes initial help fix the script in the comments

2 Likes
local TakeDamage = game:GetService("ReplicatedStorage").FireTakeDamage -- Assuming this is a RemoteEvent for damage handling

local Debris = game:GetService("Debris")

event.OnServerEvent:Connect(function(player, power, mouse)
	local character = game.Workspace:WaitForChild(player.Name)

local strength = player.Strength.Value

local punchModelName = "EnergyPunchYellow" -- Default model name

	if strength >= 100 and strength < 1000000 then
	punchModelName = "EnergyPunchYellow" -- Update this to the appropriate asset name for the red ball
	elseif strength >= 1000000 and strength < 100000000 then -- Whatever color you want this range to be in 
		punchModelName = "EnergyPunchDarkBlue"
	elseif strength >= 100000000 and strength < 1000000000 then	
		punchModelName = "EnergyPunchGreen" -- Update this to the appropriate asset name for the blue ball
	elseif strength >= 1000000000 and strength < 1000000000000 then
		punchModelName = "EnergyPunchPurple" -- Update this to the appropriate asset name for the blue ball
	elseif strength >= 1000000000000 and strength < 10000000000000 then
		punchModelName = "EnergyPunchRed" -- Update this to the appropriate asset name for the blue ball
	elseif strength >= 10000000000000 and strength < 1000000000000000 then
		punchModelName = "EnergyPunchDarkerGreen" -- Update this to the appropriate asset name for the blue ball
	elseif strength >= 1000000000000000 and strength < 10000000000000000 then
		punchModelName = "EnergyPunchWhite" -- Update this to the appropriate asset name for the blue ball 
	elseif strength >= 10000000000000000  and strength < 1000000000000000000000 then
		punchModelName = "EnergyPunchCyan" -- Update this to the appropriate asset name for the blue ball
	elseif strength >= 1000000000000000000000   and strength < 1000000000000000000000000  then
		punchModelName = "EnergyPunchGiantRed" -- Update this to the appropriate asset name for the blue ball
	elseif strength >= 1000000000000000000000000   and strength < 1000000000000000000000000000   then
		punchModelName = "EnergyPunchGiantPink" -- Update this to the appropriate asset name for the blue ball
	elseif strength >= 1000000000000000000000000000   and strength < 1000000000000000000000000000000   then
		punchModelName = "EnergyPunchGiantLime" -- Update this to the appropriate asset name for the blue ball
	elseif strength >= 1000000000000000000000000000000   and strength < 1000000000000000000000000000000000  then
		punchModelName = "EnergyPunchBigWhite" -- Update this to the appropriate asset name for the blue ball
	elseif strength >= 1000000000000000000000000000000000   and strength < 1000000000000000000000000000000000000  then
		punchModelName = "EnergyPunchBigBlack" -- Update this to the appropriate asset name for the blue ball
	elseif strength >= 1000000000000000000000000000000000000   and strength < 1000000000000000000000000000000000000000  then
		punchModelName = "EnergyPunchBigGold" -- Update this to the appropriate asset name for the blue ball
	elseif strength >= 1000000000000000000000000000000000000000   and strength < 1000000000000000000000000000000000000000000  then
		punchModelName = "EnergyPunchGiantRainbow" -- Update this to the appropriate asset name for the blue ball
	end
	
	if power == "energy punch" then
		if not game.Workspace:FindFirstChild(player.Name.."'s Energy Blast") then
			local punch = game.ServerStorage.Powers[punchModelName]:Clone()
			punch.CFrame = character.HumanoidRootPart.CFrame
			punch.Name = player.Name.."'s Energy Blast"

			punch.Parent = game.Workspace

			local antiGrav  = Instance.new("BodyForce")
			antiGrav.Force = Vector3.new(0, workspace.Gravity * punch:GetMass(), 0)
			antiGrav.Parent = punch

			punch.Velocity = CFrame.new(player.Character.HumanoidRootPart.Position, mouse).lookVector * 450

			if not player.Safe.Value then
				punch.Touched:Connect(function(hit)
					local DMG = player.Strength.Value + 1
					if hit.Parent ~= character and game.Players:GetPlayerFromCharacter(hit.Parent) then
						TakeDamage:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent), player)
						local tag = Instance.new("ObjectValue")
						tag.Value = player
						tag.Name = "creator"
						tag.Parent = hit.Parent.Humanoid


						game:GetService("Debris"):AddItem(tag, 0.5)
						script.Disabled = true
						wait(0.1)
						script.Disabled = false
					end
				end)
			end

			Debris:AddItem(punch, 1.3)
		end
	end

	if power == "Invis" then
		player.isInvisible.Value = not player.isInvisible.Value
	end
end)

Help me at least to make it so that when you gain the last strength and the last ball ripens

I want to make it so that when you get the last ball, you keep it, and for some reason I get the initial ball, help fix it

It looks like you’re not using the DMG variable anywhere. Is it supposed to be in the TakeDamage remote?

	game:GetService("ReplicatedStorage").TakeDamage:FireServer(player, hitBy)
end)

Where are you using the DMG variable?

you should probably split this giant script into a few smaller scripts

nowhere used I checked I made this script according to guides

Then this script needs to be rewritten

And I’m not very good at scripting, when I do something, I have bugs

I coped with the numbers, but u . I have a problem with the ball, now when the last ball, let’s say 100m, and I also have 100m, I got 101m, then 101m and my ball becomes the initial

try making the number requirement for the balls smaller

And how to do can you show an example of my script

maybe try deleting this, it might be the thing setting it to the initial ball

Screenshot_1
error

sorry i just meant this part a a a

Now I can’t let the balls out There is no error

it should be an issue with one of these elseif statements then, maybe look for which one it breaks at?

Listen, it doesn’t break, that’s when I go to the last ball and pump a few more times, my strength just changes to n