How to fix problem energy fist

I want to make sure that a local player apnuly 10 forces he has a red fist energy and when he apnugates 100 forces he will have blue my script

local repStorage = game:GetService("ReplicatedStorage")
local TakeDamage = repStorage.FireTakeDamage


local function newPart(name, parent, nidPoint, start, ray, pos)
	local part = Instance.new("Part", parent)
	part.Anchored = true
	part.CanCollide = false
	part.Name = name
	if pos then
		part.CFrame = pos
		part.Transparency = 1
	else
		
		part.CFrame = CFrame.new(nidPoint, start)
		part.Size = Vector3.new(1,1, ray.Direction.Magnitude)
		part.Transparency = 0.5
		part.Material = Enum.Material.SmoothPlastic
		part.Color = Color3.fromRGB(40,171,22)
	end
	
    return part
end

local function newBeam(parent, start, endPart, curve)
	local att0 = Instance.new("Attachment", start)
	local att1 = Instance.new("Attachment", endPart)
	local beam = Instance.new("Beam", parent)
	beam.Attachment0 = att0
	beam.Attachment1 = att1
	beam.CurveSize0 = curve
		
	return beam
end

local function energyFist(player, ray)
	local char = player.Character
	local nidPoint = ray.Origin + ray.Direction / 2
	local rayStart = ray.Origin
	local part = newPart(player.Name.."'s Energy Fist", game.Workspace, nidPoint, rayStart, ray, nil)
	Debris:AddItem(part, 1)
end

local function soulHarvest(player, ray, hit)
	local char = player.Character
	local rayEnd = ray.Origin + ray.Direction
	local rayStart = ray.Origin
	if hit then
		local hitChar
		if hit.Parent:IsA("Accessory") then
			hitChar = hit.Parent.Parent
		else
			hitChar = hit.Parent
		end
		
		if hitChar and hitChar:FindFirstChild("Humanoid") then
			local  endPart = newPart("end", game.Workspace, rayEnd / 2, rayStart, ray, hitChar.Head.CFrame)
			local startPart = newPart("start", game.Workspace, rayEnd / 2, rayStart, ray, char.Head.CFrame)
			local beam1 = newBeam(game.Workspace, startPart, endPart, 3)
			local beam2 = newBeam(game.Workspace, startPart, endPart, -3)
			
			hitChar.Humanoid:TakeDamage(player.Psp.Value)
			Debris:AddItem(endPart, 1)
			Debris:AddItem(startPart, 1)
			Debris:AddItem(beam1, 1)
			Debris:AddItem(beam2, 1)
		end
	end
end

local timeBetweenTp = nil

local function tp(player, mousePos)
	if timeBetweenTp then 
		if os.time() - timeBetweenTp <= 5 then
			return
		end
	end
	
	timeBetweenTp = os.time()
	local Radius = player.Psp.Value / 10000
	if Radius > 200 then
		Radius = 200
	end
	local char = player.Character
	local HRP = char:FindFirstChild("HumanoidRootPart")
	if not HRP then return end
	
	HRP.CFrame = CFrame.lookAt(HRP.Position, Vector3.new(mousePos))
	if (mousePos - HRP.Position).Magnitude <= Radius then
		HRP.Position = mousePos
	else
		HRP.Position += ((mousePos - HRP.Position).Unit) * Radius
	end
	
end
repStorage.EnergyFist.OnServerEvent:Connect(energyFist)
repStorage.SoulHarvest.OnServerEvent:Connect(soulHarvest)
repStorage.TP.OnServerEvent:Connect(tp)```

Help guys pls help me :pray: :pray::pray::pray::pray::pray::pray::pray::pray::pray:

I would like when the player reaches 100 power the energy fist was red then 1000 power was purple

What do you mean by power or color? Are you trying to change the color of something? Can you be a little more clear? Also waiting a year for an answer is interesting

I want that when the player has gained 100 strength he has a green colored energy fist and when he has gained 1000 strength he has it become yellow and when he has gained 10000 strength he has a pink standard

Guys, is this still relevant Please help.

Guys help me do what I need please I can’t do it for a year

Could at least tell us what error you meeting?

I want that when a local player reaches 100 strength he has a pink energy strike and when he reaches 1k strength he has a yellow one and TD d

There is no error, I don’t understand how to make it so that when a player reaches 100 strength, he has a pink energy strike

I can’t do it on YouTube, I couldn’t find any guides, I broke my head and gave up on it, then I came back and I want to understand how to do it

How do you detect the strength?

I understand that there must be an if and a path to strength is needed.

Can you help me? For Do it?I just don’t know

Try this:

local repStorage = game:GetService("ReplicatedStorage")
local TakeDamage = repStorage.FireTakeDamage

local function newPart(name, parent, nidPoint, start, ray, pos, color)
	local part = Instance.new("Part", parent)
	part.Anchored = true
	part.CanCollide = false
	part.Name = name
	if pos then
		part.CFrame = pos
		part.Transparency = 1
	else
		part.CFrame = CFrame.new(nidPoint, start)
		part.Size = Vector3.new(1,1, ray.Direction.Magnitude)
		part.Transparency = 0.5
		part.Material = Enum.Material.SmoothPlastic
		part.Color = color
	end

	return part
end

local function newBeam(parent, start, endPart, curve)
	local att0 = Instance.new("Attachment", start)
	local att1 = Instance.new("Attachment", endPart)
	local beam = Instance.new("Beam", parent)
	beam.Attachment0 = att0
	beam.Attachment1 = att1
	beam.CurveSize0 = curve

	return beam
end

local function energyFist(player, ray)
	local char = player.Character
	local nidPoint = ray.Origin + ray.Direction / 2
	local rayStart = ray.Origin

	local strength = player.Strength.Value
	local color
	if strength >= 10000 then
		color = Color3.fromRGB(255, 105, 180) -- Pink
	elseif strength >= 1000 then
		color = Color3.fromRGB(255, 255, 0) -- Yellow
	elseif strength >= 100 then
		color = Color3.fromRGB(40, 171, 22) -- Green
	else
		color = Color3.fromRGB(255, 255, 255) -- Default (white)
	end

	local part = newPart(player.Name.."'s Energy Fist", game.Workspace, nidPoint, rayStart, ray, nil, color)
	Debris:AddItem(part, 1)
end

local function soulHarvest(player, ray, hit)
	local char = player.Character
	local rayEnd = ray.Origin + ray.Direction
	local rayStart = ray.Origin
	if hit then
		local hitChar
		if hit.Parent:IsA("Accessory") then
			hitChar = hit.Parent.Parent
		else
			hitChar = hit.Parent
		end

		if hitChar and hitChar:FindFirstChild("Humanoid") then
			local endPart = newPart("end", game.Workspace, rayEnd / 2, rayStart, ray, hitChar.Head.CFrame, Color3.fromRGB(255, 255, 255))
			local startPart = newPart("start", game.Workspace, rayEnd / 2, rayStart, ray, char.Head.CFrame, Color3.fromRGB(255, 255, 255))
			local beam1 = newBeam(game.Workspace, startPart, endPart, 3)
			local beam2 = newBeam(game.Workspace, startPart, endPart, -3)

			hitChar.Humanoid:TakeDamage(player.Psp.Value)
			Debris:AddItem(endPart, 1)
			Debris:AddItem(startPart, 1)
			Debris:AddItem(beam1, 1)
			Debris:AddItem(beam2, 1)
		end
	end
end

local timeBetweenTp = nil

local function tp(player, mousePos)
	if timeBetweenTp then 
		if os.time() - timeBetweenTp <= 5 then
			return
		end
	end

	timeBetweenTp = os.time()
	local Radius = player.Psp.Value / 10000
	if Radius > 200 then
		Radius = 200
	end
	local char = player.Character
	local HRP = char:FindFirstChild("HumanoidRootPart")
	if not HRP then return end

	HRP.CFrame = CFrame.lookAt(HRP.Position, Vector3.new(mousePos))
	if (mousePos - HRP.Position).Magnitude <= Radius then
		HRP.Position = mousePos
	else
		HRP.Position += ((mousePos - HRP.Position).Unit) * Radius
	end

end

repStorage.EnergyFist.OnServerEvent:Connect(energyFist)
repStorage.SoulHarvest.OnServerEvent:Connect(soulHarvest)
repStorage.TP.OnServerEvent:Connect(tp)

this uses a leaderstats called Strength, that’s how we would find the Strength of the player.

ServerScriptService.PowerEventsScript:52: attempt to index nil with ‘AddItem’ - Server - PowerEventsScript:52 error

You didn’t define the Debris Service.
Add this line at the beginning:

local Debris = game:GetService("Debris")

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.