Why won't my script work

I’m trying to make a skill, with a clone effect while charging the skill.

Everything works fine except this while statement, I’ve been able to track it down and the problem is the while statement. Here is my script:

uis.InputBegan:Connect(function(input, gameProcessed)
	if gameProcessed or eCoolDown then return end
	if char:FindFirstChild("Sabre") then
		if input.KeyCode == Enum.KeyCode.E then
			InputPressing = true
			print(InputPressing)
			char.Humanoid.WalkSpeed = 30
			char.LeftEye.TrailEffect1.Enabled = true			
			char.LeftEye.TrailEffect2.Enabled = true
			char.LeftEye.EyeParticle.ParticleEmitter.Enabled = true
			char.LeftEye.EyeParticle.ParticleEmitter2.Enabled = true
			char.LeftEye.EyeParticle.ParticleEmitter3.Enabled = true

			char.RightEye.TrailEffect1.Enabled = true			
			char.RightEye.TrailEffect2.Enabled = true
			char.RightEye.EyeParticle.ParticleEmitter.Enabled = true
			char.RightEye.EyeParticle.ParticleEmitter2.Enabled = true
			char.RightEye.EyeParticle.ParticleEmitter3.Enabled = true
			spawn(hitbox)
			spawn(spawnTimeOut)
			eCoolDown = true
			wait(10)
			eCoolDown = false
		end
	end
	while InputPressing == true do --this is the problem i think
		spawn(clone)
		print("its cloning")
		wait(0.2)
	end
end)

Yeah I don’t know of any way to fix that, so if you could help me it would be great, I used a print statement for when the InputPressing changes it prints the boolean out, it comes out true which is meant to be. In the while statement I added a print statement to tell when the while loop starts.

4 Likes

Does It print error? If it does let me know.

2 Likes

No it does not print an error, if you need more details I’ll send.

1 Like

Sure, It can be only way I can help.

1 Like
local spawnTimeOut = function()
	wait(5)
	if InputPressing == true then
		InputPressing = false
		print("timeout")
		char.Humanoid.WalkSpeed = 16
		char.LeftEye.TrailEffect1.Enabled = false			
		char.LeftEye.TrailEffect2.Enabled = false
		char.LeftEye.EyeParticle.ParticleEmitter.Enabled = false
		char.LeftEye.EyeParticle.ParticleEmitter2.Enabled = false
		char.LeftEye.EyeParticle.ParticleEmitter3.Enabled = false

		char.RightEye.TrailEffect1.Enabled = false			
		char.RightEye.TrailEffect2.Enabled = false
		char.RightEye.EyeParticle.ParticleEmitter.Enabled = false
		char.RightEye.EyeParticle.ParticleEmitter2.Enabled = false
		char.RightEye.EyeParticle.ParticleEmitter3.Enabled = false
		
		char.Hitbox.CanTouch = true
		wait(1)
		char.Hitbox:Destroy()
	end
end

It could be a problem with my timeout script

1 Like

You could try putting loop in new function but I don’t think it will solve your problem (Still could try), also you could put up there “if input.KeyCode == Enum.KeyCode.E and InputPressing == false then”

Thank you, I moved the while statement to the end of uh the InputBegan and it works perfectly now, I probably would have been stuck for a while without this.

2 Likes

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