Robbing Problem

So basically what I’m trying to do is an ATM robbery which is working fine, but then I wanted to add that only Criminals can rob, if police robs it he gets nothing, the problem is I spawn in Neutral team and change to police, when I rob from police team I get nothing which is what I want, but then when I change to Criminal same thing happen, I get nothing.
How to fix this ?

local Police = game.Teams.Police
local Criminal = game.Teams.Criminal
local prompt = script.Parent
local PressEToRob = script.Parent.Parent
local ATMScreen = PressEToRob.Parent.ATMScreen
local MoneyYouGetFromRobbing = 700

local NextRobbWaitTime = 5

	local PlayerTeam = player.Team
	if PlayerTeam == Criminal then
		player.PlayerGui.ATMRobbery.MoneyRobbedText.Visible = true
		player.leaderstats.Money.Value = player.leaderstats.Money.Value + MoneyYouGetFromRobbing
		prompt.Enabled = false
		ATMScreen.Color =, 0.164706, 0)
		player.PlayerGui.ATMRobbery.MoneyRobbedText.Visible = false
		prompt.Enabled = true
		ATMScreen.Color =, 1, 0)

So does it print the players team when the prompt is triggered?

It prints the team I’m in, whenever I change team it still prints the team I spawned with

Is this a server script? Also how are you changing the players teams; via a local or server script or just in roblox studio?

It’s a server script, and I’m changing player team in a local script

1 Like

What if you try changing the players team on a server script. Because it looks like when you change the players team it doesn’t go through the server. So when you check what the players team is on the server, it will return the same value as before


Always change teams with Server Script. Only then will the Server Script used for ATM recognise that the player is in a different team since it was changed through the server which replicates everywhere.


The issue with your script is the fact that the player’s team is being changed on the client. Changing important things such as the player’s team is a horrible idea for functionality because that change will not be replicated to the server meaning that everyone else playing and the server will not be able to see that you are on a different team. If the team change must involve the client it is smart to set up what is known as a Remote Event for the player’s team change so it will be replicated to the server. If you do not know what a remote event Is you can research what it is here: Information On Remote Events

A Side Note:

Furthermore, if your game does require multiple robbable ATMs it’s smart to move some of the ATM robbery code to a module script that would handle ATM robbery. This is because Module scripts are super helpful when it comes to code that multiple instances can share.

If You Need Any Help Or Information Contact: R7#9317

1 Like