Continous printing and errors without being shown in the output?!

Hey, pri again,
I have a error with my script where it isnt erroring, but it only works correctly on the first go

Its supposed to charge the size when activated = true but after the first time it just does it without the key being held down or even being pressed at all.

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character
local Humanoid = Character.Humanoid
local Damage = 0
local Stat = Character:WaitForChild("Damage")
local Active = false
local Paper = game.ReplicatedStorage.Events.Paper
local Activated = false

UIS.InputBegan:Connect(function(Input, GPE)
    if Input.KeyCode == Enum.KeyCode.X and not GPE then
        Paper:FireServer(Mouse.Hit.p, Active)
        Activated = true
        spawn(function()
        while Activated do
            Damage = Damage + 1 
            print(Damage)
            wait(1)
        end    
        end)
    end
end)



UIS.InputEnded:Connect(function(Input, GPE)
    if Input.KeyCode == Enum.KeyCode.X and not GPE and Active == false then
        Active = true
        Activated = false
        Paper:FireServer(Mouse.Hit.p, Active, Damage)
        Damage = 0
    end
end)
-- this is the local script
ocal Paper = game.ReplicatedStorage.Events.Paper
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")

local function CreatePart()
	local Part = Instance.new("Part")
	Part.Material = "Neon"
	Part.Transparency = 0.445
	Part.Color = Color3.fromRGB(213, 115, 61)
	Part.Shape = Enum.PartType.Ball
	return Part
end

local function Weld(P0, P1)
	local Weld = Instance.new("WeldConstraint")
	Weld.Part0 = P0
	Weld.Part1 = P1
	Weld.Parent = P0
end


Paper.OnServerEvent:Connect(function(Player, MP, Active, Damage)
	if Active == false then
		Character = Player.Character
		RightHand = Character:WaitForChild("RightHand")
		Sphere = CreatePart()
		Sphere2 = CreatePart()
		
		     
            Sphere.Size = Vector3.new(1.64, 1.64, 1.64)
            Sphere.Transparency = .75
            Sphere.Name = "Sphere1"
            Sphere.CFrame = RightHand.CFrame * CFrame.new(0, -.5, 0)
            Sphere.Anchored = false
            Weld(RightHand, Sphere)
            
            Sphere2.Color= Color3.fromRGB(248, 233, 22)
            Sphere2.Size = Vector3.new(1.468, 1.468, 1.468)
            Sphere2.CFrame = Sphere.CFrame
            Sphere2.Anchored = false
            Weld(Sphere, Sphere2)
   			
			Sphere.Parent = RightHand
		Sphere2.Parent = Sphere   		
	elseif Active == true then
		Pepe = CreatePart()
	 	Pepe2 = CreatePart()
		local Character = Player.Character
		local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
		
		Pepe.Size = Vector3.new(Damage * 2, Damage * 2, Damage * 2)
		Pepe.Transparency = 0.445
		Pepe.Anchored = false
		Pepe.CFrame = HumanoidRootPart.CFrame * CFrame.new(0, 0, -5)
		Pepe.Parent = workspace
		
		Pepe2.Size = Vector3.new(Pepe.Size/ Pepe.Size, Pepe.Size)
		Pepe2.Anchored = false
		Pepe2.Transparency = 0.45
		Pepe2.CFrame = Pepe.CFrame
		Pepe2.Parent = Pepe
		Weld(Pepe, Pepe2)
		
		local BodyVelocity = Instance.new("BodyVelocity")
		BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		BodyVelocity.Velocity = (MP - HumanoidRootPart.Position).Unit * 250
		BodyVelocity.Parent = Pepe
		end
end)
-- this is the script in serverscriptservice

After one touch of the key after the second attempt, this continues to print
image

Ive tried asking for help on offsite places but nobody seems to be able to help me :frowning:
Id appreciate any tips or help of any kind!

Thanks again,
pri

Hello there. please try

print(start)
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character
local Humanoid = Character.Humanoid
local Damage = 0
local Stat = Character:WaitForChild("Damage")
local Active = false
local Paper = game.ReplicatedStorage.Events.Paper
local Activated = false

UIS.InputBegan:Connect(function(Input, GPE)
    if Input.KeyCode == Enum.KeyCode.X and not GPE then
        Paper:FireServer(Mouse.Hit.p, Active)
        Activated = true
        spawn(function()
        while Activated do
            Damage = Damage + 1 
            print(Damage)
            wait(1)
        end    
        end)
    end
end)



UIS.InputEnded:Connect(function(Input, GPE)
    if Input.KeyCode == Enum.KeyCode.X and not GPE and Active == false then
        Active = true
        Activated = false
        Paper:FireServer(Mouse.Hit.p, Active, Damage)
        Damage = 0
    end
end)
-- this is the local script
local Paper = game.ReplicatedStorage.Events.Paper
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")

local function CreatePart()
	local Part = Instance.new("Part")
	Part.Material = "Neon"
	Part.Transparency = 0.445
	Part.Color = Color3.fromRGB(213, 115, 61)
	Part.Shape = Enum.PartType.Ball
	return Part
end

local function Weld(P0, P1)
	local Weld = Instance.new("WeldConstraint")
	Weld.Part0 = P0
	Weld.Part1 = P1
	Weld.Parent = P0
end


Paper.OnServerEvent:Connect(function(Player, MP, Active, Damage)
	if Active == false then
		Character = Player.Character
		RightHand = Character:WaitForChild("RightHand")
		Sphere = CreatePart()
		Sphere2 = CreatePart()
		
		     
            Sphere.Size = Vector3.new(1.64, 1.64, 1.64)
            Sphere.Transparency = .75
            Sphere.Name = "Sphere1"
            Sphere.CFrame = RightHand.CFrame * CFrame.new(0, -.5, 0)
            Sphere.Anchored = false
            Weld(RightHand, Sphere)
            
            Sphere2.Color= Color3.fromRGB(248, 233, 22)
            Sphere2.Size = Vector3.new(1.468, 1.468, 1.468)
            Sphere2.CFrame = Sphere.CFrame
            Sphere2.Anchored = false
            Weld(Sphere, Sphere2)
   			
			Sphere.Parent = RightHand
		Sphere2.Parent = Sphere   		
	elseif Active == true then
		Pepe = CreatePart()
	 	Pepe2 = CreatePart()
		local Character = Player.Character
		local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
		
		Pepe.Size = Vector3.new(Damage * 2, Damage * 2, Damage * 2)
		Pepe.Transparency = 0.445
		Pepe.Anchored = false
		Pepe.CFrame = HumanoidRootPart.CFrame * CFrame.new(0, 0, -5)
		Pepe.Parent = workspace
		
		Pepe2.Size = Vector3.new(Pepe.Size/ Pepe.Size, Pepe.Size)
		Pepe2.Anchored = false
		Pepe2.Transparency = 0.45
		Pepe2.CFrame = Pepe.CFrame
		Pepe2.Parent = Pepe
		Weld(Pepe, Pepe2)
		
		local BodyVelocity = Instance.new("BodyVelocity")
		BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		BodyVelocity.Velocity = (MP - HumanoidRootPart.Position).Unit * 250
		BodyVelocity.Parent = Pepe
		end
end)
print(end)

and tell me what happens

When pressing the key, does it print every second? If so, this is because Activated is still true, so the while Activated do is still running every second, increasing damage and printing it.

Alright then, (30 charssss limit)

Yes, but in the inputended i changed the value from true back to false

if Input.KeyCode == Enum.KeyCode.X and not GPE and active == true and then
Active == true
Activated = false

You have to put in the inputbegan script that sets active to false to fix it I think

image
It indeed printed start and end, but the glitch is still occuring
image

Well you could do

local Paper = game.ReplicatedStorage:WaitForChild("Events"):WaitForChild("Paper")

To fix the error

Im confused by this statement. (30 charsss)

Ill try that but it seems redundant.

image
Tried it, its still erroring for some reason.
line 51

Oh, I know, in the localscript in the UIS.InputBegan function, when it fires paper, it doesn’t provide the damage parameter, so damage ends up being nil causing an error since nil cannot be multiplied

Ill check but im sure this may be inaccurate as it has been fired in the InputEnded but thanks for trying. Ill respond after i finish checking

On second thought after a huge oh moment, i noticed that in my first.OnServerEvent:Connect()
Damage wasnt being sent in as a argument. im not sure where it involves the constant duplication but ill check.

Update, it hasnt worked. (30 charss)