I'm trying to make it so if you're on the team Criminal and you have the items Taser or HandCuffs in your backpack, it gets removed. I tried doing this but it didn't work.
01 | local players = game:GetService( "Players" ) |
02 | local criminals = game.Teams.Criminal |
03 |
04 | players.PlayerAdded:Connect( function (player) |
05 | player.Team = criminals |
06 | player.CharacterAdded:Connect( function (character) |
07 | character.Humanoid.Died:Connect( function () |
08 | if player.Team = = criminals then |
09 | while true do |
10 | game.Players.LocalPlayer.Backpack.Taser:Destroy() |
11 | game.Players.LocalPlayer.Backpack.HandCuffs:Destroy() |
12 | end |
13 | end |
14 | end ) |
15 | end ) |
16 | end ) |
It would be better if you added a StringValue on the player to tell which team he is on instead of just getting it from the Team Service, I'm guessing that script is in the StarterGui, so try this:
01 | wait( 1 ) |
02 |
03 | Player = workspace:FindFirstChild(script.Parent.Parent.Name) |
04 |
05 | if not Player:FindFirstChild( "Team" ) then |
06 | local value = Instance.new( "StringValue" ) |
07 | value.Name = 'Team' |
08 | value.Parent = Player |
09 | end |
10 |
11 | wait() |
12 | if Player.Team.Value ~ = "Criminal" then |
13 | wait() |
14 | else |
15 | if script.Parent.Parent.Backpack:FindFirstChild( "Taser" ) and script.Parent.Parent.Backpack:FindFirstChild( "HandCuffs" ) then |