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

Friends only spawn without use of a team?

Asked by
X8311 0
6 years ago

I've been trying to make a spawn that detects if a player is on your friends list, and then spawns them there if they are. I don't want to utilize teams for this, and have been having trouble without the use of teams. I was wondering if anyone could help me out with this. Thanks

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago
local friendId = 0 --replace

local friendSpawnPos = workspace.friendSpawn.Position --replace

local isFriendsCache = setmetatable({}, {__index = function(self, i)
    self[i] = game:GetService("Players")[i]:IsFriendsWith(friendId)
    return self[i]
end})

game:GetService("Players").PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        if isFriendsCache[plr.Name] then
            char:WaitForChild"HumanoidRootPart".CFrame = CFrame.new(friendSpawnPos)
        end
    end)
end)
Ad

Answer this question