Only Developer Forum feature requests should be posted here.
Use #feature-requests for Roblox-related feature requests. #feature-requests
Be as specific as possible, give your post a clear and descriptive title, and focus on problems and use cases, rather than proposed solutions.
As a Roblox developer, it is currently too hard to detect when a player was spawned on a certain spawn location.
If Roblox is able to address this issue, it would improve my experience using the forum because I would be able to create procedural meeting tables in the following scenario:
Players would start a party and get teleported to a new place. One by one they spawn in on a spawn location, and when they do it gets deleted, making them sit in the chair the spawn location was on and making sure no one else spawns there.
EDIT: this is my first post and did I do this right?
You posted an engine feature request. You can’t post features requests. You need to join the @AllowFeatureRequests group first.
The request you are asking for has not a lot of use cases and would be used very little so I doubt roblox would add it. Till then, just get the magnitude.
Instead of spawn locations, you should consider building an array of positions in the meeting room, and then removing them once a player spawns and gets placed in that location.
But if you’d like to use SpawnLocations still, If you have all the spawns in a folder, you could detect which one the player spawns at:
-- Server script in ServerScriptService
local Players = game:GetService("Players")
local SpawnLocations = workspace:WaitForChild("SpawnLocationsFolder") -- Set this
Players.PlayerAdded:Connect(function(player : Player)
player.CharacterAdded:Connect(function(character : Model)
-- Wait for the character to load and for the HumanoidRootPart to be available
local humanoidRootPart = character:WaitForChild("HumanoidRootPart") :: BasePart
-- You may end up having a race condition depending on the internal logic of SpawnLocations so lets wait a frame:
task.wait()
-- Find the closest spawn location to the player's character
local closestSpawnLocation = nil
local closestDistance = math.huge
for _, spawnLocation in ipairs(SpawnLocations:GetChildren()) do
if spawnLocation:IsA("SpawnLocation") then
-- Do a distance check to find the closest spawn location
local distance = (humanoidRootPart.Position - spawnLocation.Position).Magnitude
if distance < closestDistance then
closestDistance = distance
closestSpawnLocation = spawnLocation
end
end
end
if closestSpawnLocation then
print("Found the closest spawn location: ", closestSpawnLocation)
-- TODO: Do something now that you know where they spawned.
else
warn("No spawn locations found for player: " .. player.Name)
end
end)
end)