Explanation: So I'm trying to make a script for a hospital roleplay game. When the player enters the game, the game auto-detects whether they are in a group or not and whether they have enough rank. If the player has enough rank and is in the group, the player will automatically be on the team "Hospital Staff", otherwise, the player will automatically be on team "Patient". There's 2 teams, 1 is called "Hospital Staff". Another team is called "Patient". My problem here is that when a player changed the team, the game won't detect, i've tried to use GetPropertyChangedSignal function but it does not detect as well..
I Have 3 scripts.
First Script: Located In StarterPack Named "TeamChooseLocal". It's a local script as u can tell from the name. This is the script for detecting whether they are in the group and have enough rank.
Second Script: Located In a part named "ReceptionDoor" in Workspace, Named "ReceptionDoorAccessServer". It's a server script (as you can tell). This is the script where it detects which team a player is in and whether to give access to the reception door to a player.
Third Script: Located in StarterPack Named "ReceptionDoorAccessLocal". Well, you know what type of script is that. This is the script where is it gets the rank from the group to see if player meet the requirement when they select "Hospital Staff" Rank and check if they are in the group as well so that they will have access to the reception door if they did.
Here are the scripts.
TeamChooseLocal:
local Player = game.Players.LocalPlayer
local Teams = game:GetService("Teams")
local ReceptionDoorEvent = game:GetService("ReplicatedStorage"):WaitForChild("EventsFolder"):WaitForChild("ReceptionDoorAccessEvent")
if Player:IsInGroup(5786709) and Player:GetRankInGroup(5786709) > 1 then
print("Player Is In Group: Robloxia City Hospital")
print("Player's Rank Is: "..Player:GetRankInGroup(5786709))
Player.Team = Teams["Hospital Staff"]
print("Team Changed, Player's Team Is Hospital Staff")
ReceptionDoorEvent:FireServer()
print("FiredServer")
elseif Player:IsInGroup(5786709) and Player:GetRankInGroup(5786709) == 1 then
print("Player Is In Group: Robloxia City Hospital")
print("Player's Rank Is: "..Player:GetRankInGroup(5786709))
Player.Team = Teams.Patient
print("Team Changed, Player's Team Is 'Patient'")
ReceptionDoorEvent:FireServer()
print("FiredServer")
else
print("Player Is Not In Group: Robloxia City Hospital!")
Player.Team = Teams.Patient
print("Team Changed, Player's Team Is 'Patient'")
ReceptionDoorEvent:FireServer()
print("FiredServer")
end
ReceptionDoorAccessServer:
local ReceptionDoorEvent = game:GetService("ReplicatedStorage"):WaitForChild("EventsFolder"):WaitForChild("ReceptionDoorAccessEvent")
local ReceptionDoorEvent2 = game:GetService("ReplicatedStorage"):WaitForChild("EventsFolder"):WaitForChild("ReceptionDoorAccessEvent2")
local Touched = false
local Teams = game:GetService("Teams")
game.Players.PlayerAdded:Connect(function()
script.Parent.Touched:Connect(function(ReceptionDoor)
if ReceptionDoor.Parent:FindFirstChild("HumanoidRootPart") then
if Touched == false then
Touched = true
print("HumanoidRootPart Found")
ReceptionDoorEvent.OnServerEvent:Connect(function(Player)
print("ReceptionDoorEvent Received Signal") -- supposed to put "GetPropertyChangedSignal" function after this but it doesn't work...
if Player.Team == Teams["Hospital Staff"] then
print("Player Is In Team: Hospital Staff, Access Granted!")
ReceptionDoorEvent2:FireClient(Player)
print("FiredClient")
elseif Player.Team == Teams.Patient then
print("Player Is In Team: Patient, Access Not Granted!")
Touched = true
end
end)
end
elseif ReceptionDoor.Parent:FindFirstChild("Torso")then
if Touched == false then
Touched = true
print("Torso Found")
ReceptionDoorEvent.OnServerEvent:Connect(function(Player)
print("ReceptionDoorEvent Received Signal") -- supposed to put "GetPropertyChangedSignal" function after this too...
if Player.Team == Teams["Hospital Staff"] then
print("Player Is In Team: Hospital Staff, Access Granted!")
ReceptionDoorEvent2:FireClient(Player)
print("FiredClient")
elseif Player.Team == Teams.Patient then
print("Player Is In Team: Patient, Access Not Granted!")
Touched = true
end
end)
end
end
ReceptionDoorEvent2.OnServerEvent:Connect(function()
Touched = false
end)
end)
end)
ReceptionDoorAccessLocal:
local ReceptionDoorEvent2 = game:GetService("ReplicatedStorage"):WaitForChild("EventsFolder"):WaitForChild("ReceptionDoorAccessEvent2")
local LocalPlayer = game.Players.LocalPlayer
local ActualReceptionDoor = game.Workspace:WaitForChild("ReceptionDoor")
local Teams = game:GetService("Teams")
ReceptionDoorEvent2.OnClientEvent:Connect(function()
print("ReceptionDoorEvent2 Received Signal")
if LocalPlayer:GetRankInGroup(5786709) >= 3 then
print(LocalPlayer:GetRankInGroup(5786709))
ActualReceptionDoor.Transparency = 0.5
ActualReceptionDoor.CanCollide = false
wait(1)
ActualReceptionDoor.Transparency = 0
ActualReceptionDoor.CanCollide = true
ReceptionDoorEvent2:FireServer()
end
end)

6 comments
Hi, I tried the "GetPropertyChangedSIgnal('TeamColor')" function you said but still doesn't work. I tried to print("Team Change Detected") after the "GetPropertyChangedSignal" function but it doesn't print. However, the ServerScript still receives the Signal from the LocalScript as I tried to print("ReceptionDoorEvent Received Signal") and it printed.
Ow by the way Player.Team works for me tho. Everything works well except for the "GetPropertyChangedSignal" function. It didn't even print any error....
Dude, do you have discord? Maybe can you add me and guide me? My ID is: Mr1O1#9346 Thanks
sure
just sent u one
Arsubia12#0546