I'm currently creating a NPC that has a Billboard Gui located inside of the head and I have put a text button inside of the Billboard Gui. My goal is to make it so that once you are in a certain distance of the dummy, the Gui pops up and you can press Q to place the camera to a camera part. Then it activates another gui meant for chatting with the NPC. So far, I've made it so that the Billboard Gui pops up in a certain range, but I can't seem to figure out how to make the button clickable, much less keybind it to Q. The name of the camera part is MasterCamera. This is my code:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local cam = game.Workspace.CurrentCamera
mouse.KeyDown:connect(function(key)
if key:lower() == "q" then
print("keyed")
cam.CameraSubject = game.Workspace.MasterCamera
cam.CameraType = "Scriptable"
while wait() do
cam.CFrame = game.Workspace.MasterCamera.CFrame
end
end
end)
I'm stuck on how to get it so it is in a certain range. Please help me, any responses are appreciated!

8 comments
please use the codeblock option to make your code easier to read.
The script btw is in the StarterGui, one of the only places it will actually work, even though it's broken.
also keydown is deprecated use user input service
can I contact you in discord? I would like to help you but cant because I dont exactly know how due to lack of knowledge about the problem
ok
sure, you can contact me in discord my discord is silver#0562
oh nice
lemme see