Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I know if the player is close to something without multiple if statements?

Asked by 5 years ago
Edited 5 years ago
    HumanoidRootPartWait = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
  
    
  
  Coal = workspace.Coal
  
  Stick = workspace.Sticks
  
  HumanoidRootPart = game.Players.LocalPlayer.Character.HumanoidRootPart
  
  LocalPlayer = game.Players.LocalPlayer
  
  while wait(1) do
  
  if (HumanoidRootPart.Position - Stick.Position).Magnitude < 10 or (HumanoidRootPart.Position - Coal.Position).Magnitude < 10 then
  
  LocalPlayer.PlayerGui.ScreenGui.Enabled = true
  
  else
  
  LocalPlayer.PlayerGui.ScreenGui.Enabled = false
  
  end
  
  end
  
    
  
    
  
    
  
    
  
  LocalPlayer.PlayerGui.ScreenGui.TextButton.Activated:connect(function()
  
  end)
  

Is there a way to know which object the player is close to? Sticks or coal in this place, without having multiple if statements to check what it is close to.?

1 answer

Log in to vote
0
Answered by 5 years ago

You could have a 'hitbox' and detect if that's touched, and use a remoteevent to enable it using 'FireClient'. I do not know any other way.

Ad

Answer this question