I need help why this script isnt working

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse() 
local Equiped = false
local character = Player.Character 

if not character or not character.Parent then
	character = Player.CharacterAdded:wait() 
end


local Enabled = false
local Kicked = false 
local Power = 10

local Holding = false
Mouse.Button1Down:Connect(function() 

	Holding = true
	while Holding == true do
	
		wait()
		print(Power)

				Power += 3.42
			
		if Power >= 80 then
			Power = 80
			
			end
		end
	

end)

Mouse.Button1Up:Connect(function()
		Holding = false
		

		
		
		Kicked = true
		
		
print(Kicked)
	task.wait(0.5) -- Waits 0.7 seconds before proceeding
	
	
	Kicked = false -- Setting the react to be ineligible
	print(Kicked)
    
		Power = 10
	while Kicked == true do
		wait()
	

		if (character["Right Leg"].Position - game.Workspace.Ball.Position).Magnitude <= 5 then

      
		game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent"):FireServer(game.Workspace.Ball)

		local F = Instance.new("BodyVelocity") -- Creates a Force
		F.P = 9
		F.Parent = game.Workspace.Ball -- Makes the force act on the ball
		F.Name = script.Name -- Make the force's name the script's name
		F.velocity = character.HumanoidRootPart.CFrame.lookVector * Power + Vector3.new(0,Power - 40,0)  -- The force is where the Right Leg is looking (so if your right leg was looking towards the goal then the ball would go to the goal) and its given a certain value to go against (the higher the number, the faster the ball would go)


		F.maxForce = Vector3.new(math.huge,math.huge,math.huge) -- The maximum force it's allowed to give the ball 
			game.Debris:AddItem(F,0.3) -- This destroys the Force within 0.3 seconds without stopping the code so it doesn't keep the ball moving
			
		end

end

end)

The power prints but the ball doesn’t kick when I let go of my mouse.

put the while loop before setting the kicked to false…

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