Hey there,
I wanted to know how to make a system where when a person touches a part a remote event fires which checks if a person is in a select group, if is then would print valid ID else would say Invalid ID
You will need to use three main things I believe, which are the .Touched event on the Part. Remote events and the Player:IsInGroup
function. I can’t really give you the whole script as that wouldn’t teach you much, but you can explore these API References and create it your self.
There is no reason to have a remote event in all of this. It just makes this more complex. You can use a Touched event on the server.
local PlayersService = game:GetService("Players")
local Part = script.Parent
local Busy = {}
local GroupIds = {
3650991,
6349269,
372
}
local function CheckForGroups(Hit)
local Player = PlayersService:GetPlayerFromCharacter(Hit.Parent)
if (Player and (not Busy[Player])) then
Busy[Player] = true
for i, GroupId in pairs(GroupIds) do
local Success, Response = pcall(Player.IsInGroup, Player, GroupId)
if (Success) then
if (Response) then
print("Player is in: ", GroupId)
end
else
warn("Unable to check whether player is in group!", Response)
end
end
wait(1)
Busy[Player] = false
end
end
Part.Touched:Connect(CheckForGroups)
Thanks for the help I will try to modify it accordingly
BasePart is the Primary Part of a model, right?
I have used a script for this for getting role in group
local groupId = "groupId"
Player:GetRoleInGroup(groupId)