I have started with my Proximity Prompt Door and would like to make it group locked.
Please help me thanks soli
1 Like
Are ya meaning it will only open/close if the player is in certain group?
some example, localScript in StartPlayerScript :
local Player = game.Players.LocalPlayer
local ProximityPrompt = game.Workspace.Part.ProximityPrompt
ProximityPrompt.Triggered:Connect(function()
if not Player:IsInGroup(1) then -- (Replace 1 with your group number)
print(Player.Name .. " is not in a group, the door won't open!")
else
print(Player.Name .. " is in the group! Great!")
-- Run code here!
end
end)
Script Inside Proximity Prompt, Make sure proximity is inside the part/door
local groupid = 000000
script.Parent.Triggered:Connect(function(Player)
if Player:IsInGroup(groupid) then
if script.Parent.Parent.CanCollide == true then
script.Parent.Parent.CanCollide = false
else
script.Parent.Parent.CanCollide = true
end
end
end)
IsInGroup on a server script caches the initial response.
local prompt = script.Parent
local door = prompt.Parent
local groupId = 0 --Change to ID of group.
prompt.Triggered:Connect(function(player)
local success, result = pcall(function()
return player:IsInGroup(groupId)
end)
if success then
if result then
door.CanCollide = false
else
door.CanCollide = true
end
else
warn(result)
end
end)