I have made some ship spawners which take money, then spawn a ship when touched. The problem is, if a ship is in the way, the spawners still work, which obviously causes problems. I was planning on disabling the spawners if another ship is too close, but I have no idea how to go about it. Anyone there to point me in the right direction? Thanks in advance.
✓ ANSWER ACCEPTED
Disabling spawners if another vehicle is too close?
2 answers
✓ Accepted answer
###You can use Magnitude to check if it's within a certain distance. This will be an example with the player's distance and with the ship's distance. If you'd like to check between the spawner and the ship, change the HumanoidRootPart to wherever your spawn is.
-- Add this somewhere in your touched event
-- Assuming you already got the humanoid
local minDistance = 50 -- example. the closest it can be
local mag = (hit.Parent.HumanoidRootPart.Position - script.Parent.Position)
if mag.Magnitude <= minDistance then
-- code. this is all i'm giving since you only asked for a point in the right direction.
end
There is an Enabled attribute in a spawner, you can configure it to what you would like, true or false. False being the condition you'd like it in.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thank you, incapaz!