ImputBegan script not working

I have a sctipt that should change the parent and position of a mesh when t is pressed. But for some reason it doesnt work.

useri.InputBegan:Connect(function(input)
	print("Input made")
	if input.KeyCode == Enum.KeyCode.T then
		print("Input correct")
		for i, v in pairs(workspace.LadderStuff:GetDescendants()) do
			print("Checking")
			if v.ClassName == "MeshPart" and v.Parent == workspace.LadderStuff.Stages or v.Parent == workspace.LadderStuff.Active then
				v.Parent = workspace.LadderStuff.Stages 
				v.CFrame = workspace.LadderStuff.MainPart.CFrame
			end
		end
	end
end)

Notes:
-Nothing prints
-This is a piece of a larger script with another 2 imput began events which work.

I hope this Helps :slight_smile:

If it’s not a local script it wouldn’t work.


I would need more info than that to solve your problem.

image

Make sure the LocalScript is either in StarterGui, StarterPack or in a StarterPlayer folder.

ReplicatedFirst too but it’s not recomended to do that

1 Like

You forgot the second parameter

   InputBegan:Connect(function(input,            gameprocessedevent)

end)

If there are other InputBegan events, that is probably your issue. Combine them all into one InputBegan.

InputBegan:Connec(function(input)
    if input.KeyCode == Enum.KeyCode.T then
    elseif input.KeyCode == Enum.KeyCode.E then
    elseif input.KeyCode == Enum.KeyCode.Q then
    end
end)

Function arguments are always optional, if he doesn’t need it then he doesn’t need to include it.

Did a couple things and fixed it, it was an easy issue to fix, thanks to everyone who replied!