I'm trying to make it so when you press "q" on your keyboard and you are within a radius of a brick, it will print "q" in the output. Why won't this work?
player = game.Players.LocalPlayer
Mouse = player:GetMouse()
function onTouch()
wait()
for i, v in pairs(game.Players:GetChildren()) do
if (v.Character.Torso.Position - script.Parent.Position).magnitude <=4 then
local UIS = game:GetService("UserInputService")
UIS.InputBegan:connect(function(Key, GPE)
if Key.KeyCode == Enum.KeyCode.Q and not GPE then
print"q"
end
end)
--print"f"
wait()
else
print"not in the radius"
end
end
end
script.Parent.Touched:connect(onTouch)

1 comment
As a side note, I'd like to point out that the calls to "wait()" in your case are not necessary.