Why am I getting this error?

My error:

  09:14:50.874  Workspace.MasonX890.UI.UI_Main:185: Script timeout: exhausted allowed execution time 

My Script:

function KeyClick(Type)
	if Type.Name == "NPC" then
		PopupGui.Button:TweenSize(
			UDim2.new(0.3, 0,0.3, 0),
			"Out",
			"Quad",
			.1,
			true
		)
		wait(.1)
		PopupGui.Button:TweenSize(
			UDim2.new(0.25, 0,0.25, 0),
			"Out",
			"Quad",
			.1,
			true
		)
	end
	repeat	
	until KeyDown == false
	
end

UserInputServer.InputBegan:Connect(function(Key, Gameprocess)
	if Key.KeyCode == Enum.KeyCode.E and AlreadyPlayed == true  and not Gameprocess then
		KeyDown = true
		KeyClick(PartToAdonee)
	end	
end)

UserInputServer.InputEnded:Connect(function(Key, Gameprocess)
	if Key.KeyCode == Enum.KeyCode.E and AlreadyPlayed == true  and not Gameprocess then
		KeyDown = false
		KeyClick(PartToAdonee)
	end	
end)

try this

function KeyClick(Type)
	if Type.Name == "NPC" then
		PopupGui.Button:TweenSize(
			UDim2.new(0.3, 0,0.3, 0),
			"Out",
			"Quad",
			.1,
			true
		)
		wait(.1)
		PopupGui.Button:TweenSize(
			UDim2.new(0.25, 0,0.25, 0),
			"Out",
			"Quad",
			.1,
			true
		)
	end
	repeat	task.wait()
	until KeyDown == false
	
end

UserInputServer.InputBegan:Connect(function(Key, Gameprocess)
	if Key.KeyCode == Enum.KeyCode.E and AlreadyPlayed == true  and not Gameprocess then
		KeyDown = true
		KeyClick(PartToAdonee)
	end	
end)

UserInputServer.InputEnded:Connect(function(Key, Gameprocess)
	if Key.KeyCode == Enum.KeyCode.E and AlreadyPlayed == true  and not Gameprocess then
		KeyDown = false
		KeyClick(PartToAdonee)
	end	
end)

The error appears due to the overload of looping, so the error kind of saves the computer from crashing.

1 Like

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