I'm making a game where the player has to click objects to activate them. I used the mouse property of the player. Here's and example of what my script looks like,
--In a local script in StarterPack
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:connect(function()
local Target = mouse.Target
if Target and Target.Name == "ChangePlatform" then
Target:Destroy()--Example
end
end)
However, the player is able to click the object from an extreme distance. How can I limit this distance?
I tried looking this question up but couldn't find a solution.
You might have to get the player's torso and measure the distance from the torso and the object but I don't know how to do that. Also, if you do this would it cause a lot of lag?
Any help would be awesome.
Thank You.

2 comments
Great wanseer! This will help me in make problem greatly.
:D I worked very hard on my wanseer! But what did you think of my answer?