Hi, I am back, sorry about inactivity, Today i have a question about how do i get if a player is within 7 studs of a object, I am making a microphone, and therefore i dont want everybody that chats putting a message on the screen. The script is inside the actual microphone object, Here is my code:
game.Players.PlayerAdded:connect(function(player)
-- when `player` joins the game, start listening for their chatting
player.Chatted:connect(function(message)
-- and each time they chat, do stuff with `player` and `message`
processCommand(player, message)
end)
end)
function processCommand(speaker, message)
-- if someone chatted "whoami"
local playerW7s = true --i dont know how to get if a player is within 7 studs of a object
print("Checking if player is within 7 studs..")
if(playerW7s == true) then
local msg = Instance.new("Message", game.Workspace)
msg.Text = message
wait(5)
msg:Destroy()
end
end
Please help, thanks

3 comments
In a future, more advanced version of this script you'll want to use a coroutine to create and destroy the message, and you'll want to check that the player has a Torso (i.e. exists in the physical world) before testing for distance.
Duckwit, it wont work, I tried typing Whoami WHOami, etc. and it wont say anything. so its not tested
There was a typographical error. I wrote "=" in the conditional rather than "==", I've fixed it now. It's always assumed on ScriptingHelpers that you can test things for yourself. We're not here to script for you, but to get you set in the right direction.