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

[SOLVED] "GetPropertyChangedSignal" not functioning, any idea why?

Asked by 4 years ago
Edited 2 years ago

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)

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

okay, first up, great explanation.. I wish everybody would explain their problems in as much detail as you did..

There's multiple problems in your scripts:

1.I am pretty sure you can only check the rank of a player in a group from the server

2.a player's team is not dictated by a team object, instead it's controlled by the TeamColor of a team object. Which means to set the player's team, you have to player.TeamColor = TeamObject.TeamColor

3.you don't really need remote event's to give access to a door, unless absolutely neccessary

now here's how you can do the same thing:

in a server script

local Players = game:GetService("Players")
local Teams = game:GetService("Teams");

local staff = Teams["Hospital Staff"]
local patients = Teams.Patients

Players.PlayerAdded:Connect(function(player)
    if(player:IsInGroup(5786709)) then
        local rank  = player:IsInGroup(5786709)
        if(rank > 1) then
            player.TeamColor =  staff.TeamColor
            print("Is staff")
        elseif(rank == 1) then
            player.TeamColor = patients.TeamColor
            print("Is patient")
        end
    else
        print("Player is not in group")
    end
end)

LocalSCript

local Players = game:GetService("Players")
local Teams = game:GetService("Teams");
local door = nil--set this to the door part;

door.Touched:Connect(function(part)
    local player = Players.LocalPlayer
    local character = player.Character

    local isStaff  = player.Team == Teams["Hospital Staff"]
    local isInGroup = player:IsInGroup(5786709)

    if part.Parent == character and character and isInGroup and isStaff then
        door.CanCollide = false
        door.Transparancy = 0.5
        wait(3);
        door.CanCollide = true
        door.Transparancy = 0
    end
end)

Object:GetPropertyChangedSignal takes a property name,like TeamColor.. you can check when the player' team changes by doing

player:GetPropertyChangedSignal("TeamColor"):Connect(function()
    print("Player's team changed")
end)

hopefully this helps, lemme know if you need more help

0
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. guest_20I8 266 — 4y
0
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.... guest_20I8 266 — 4y
0
Dude, do you have discord? Maybe can you add me and guide me? My ID is: Mr1O1#9346 Thanks guest_20I8 266 — 4y
0
sure User#23252 26 — 4y
View all comments (2 more)
0
just sent u one User#23252 26 — 4y
0
Arsubia12#0546 User#23252 26 — 4y
Ad

Answer this question