Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't this team changer delete'r working?

local Player = script.Parent.Parent.Parent


	
if script.Parent.Parent.Name == "PlayerGui" then
		
	if Player.Team.TeamColor == BrickColor.new("Dark stone grey") then -- Checks if the team is a prisoner
		print("Prisoner")
		script.Parent:Destroy() -- removes it if your team is a prisoner
	end
		
	if Player.Team.TeamColor == BrickColor.new("White") then -- checks if your team is a civilian
		print("Civilian")
	end
		
end

How it works: it sees if you're a prisoner then deletes the GUI so you cant change and get unjailed and prints "Prisoner"

If you're a civilian then it just prints "civilian"...

1 comment

0

Could you please accept my answer if I helped you?

1 answer

✓ Accepted answer

It did work, though it only checked once. The if will not execute on its own each time.

Using the GetPropertyChangedSignal function we can listen for a specific property change.

local Player = game:GetService("Players").LocalPlayer

Player:GetPropertyChangedSignal("Team"):Connect(function()
    if Player.Team.TeamColor == BrickColor.new("Dark stone grey") then
        print("Prisoner")
        script.Parent:Destroy()
    elseif Player.Team.TeamColor == BrickColor.new("White") then
        print("Civilian")
    end
end)

Basically the code executes each time the team changes and only when the team changes. If you do not know about events already check them out here: events


######Hopefully this answered your question and if it did, then don't forget to hit that "Accept Answer" button. It helps the both of us out :) ######If you have any other questions then feel free to leave them down in the comments.

1 comment

0

thanks fam

This discussion is preserved as it was. New answers, comments, and votes are closed.