Robbery Script isn't working! Please, help!

Hey! I am having trouble with my robbery script, I have a bank and jewlery store and they are both put together in 1 script, so 1 thing breaks in the script, both breaks.

Line of code with error:

253                  end) --Error
254	         end
255    end
256 JewelParts.JewelryVentHit.Touched:Connect(function(Hit)
257	local targetHumanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
258	if targetHumanoid then
259		targetHumanoid.Parent.HumanoidRootPart.CFrame = workspace.TeleportPoints.JewelryPoint.CFrame
260	    end
261 end)
261 JewelryZone.PlayerAdded:Connect(function(Player)
262		game.ReplicatedStorage.Remotes.System:FireClient(Player,"guiMessage",{"Game Help","You're robbing the jewelry store! Touch case glass to break it, then touch the rings to steal them! Make sure you escape before the time is up!",8})
263	if not JewelryDataValues.InProgress and JewelryDataValues.Cooldown then
		Player.Character.HumanoidRootPart.CFrame = workspace.TeleportPoints.JewelryPoint.CFrame	
264	    end
265 end)
266 --// Loops
267 JewelryZone:initLoop(0.1)
268 BankZone:initLoop(0.1)

Output Picture: https://gyazo.com/6d18ad34b84bcc7016ed2e1ae49fe5f4

Anyone able to help me fix it?

1 Like

you forgot to put end somewhere, probaly at line 20

a common mistake i see most of the time, while you are scripting,
sometimes you accidentally skip a end, and add that “End” too far making some function run at the same time and making a big problem

1 Like

https://gyazo.com/f72b86a4df5e1bd3ceb99cbe90ace828
Line 16-20

1 Like

can you post that line of the script here? when the function starts

the problem is a misplaced end, for sure

1 Like

Are you comfortable sending the whole script? If you do that, then we will be able to investigate it ourselves and get this solved faster.

1 Like

Yeah, I can do that.

print("[Stage 2/nil] Loading server "..script.Name);local startTick = tick()
local ZoneModule = require(4958963725)
local Regions = workspace.Regions
local TweenService = game:GetService("TweenService")

local function makeLoot(Player)
	if not Player.Character:FindFirstChild("Loot") and (Player.Team == game.Teams.Rebels or Player.Team == game.Teams.Citizens or tostring(Player.Team) == "Demolisher") then
		local newValue = Instance.new("NumberValue")
		newValue.Parent = Player.Character
		newValue.Name = "Loot"
		newValue.Value = 0
		local newMax = Instance.new("NumberValue")
		newMax.Parent = newValue
		newMax.Name = "MaxLoot"
		newMax.Value = 5000
	end	
end
for _,v in pairs(workspace.LootPoints:GetChildren()) do
	if v:IsA("Part") then
		v.Touched:Connect(function(Hit)
		end)
			local Humanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
			if Humanoid then
				local Player = game.Players:GetPlayerFromCharacter(Humanoid.Parent)
				if Player then
					if Player.Character:FindFirstChild("Loot") then
						local PlayerCredits = Player:WaitForChild("PlayerData"):WaitForChild("Credits")
						PlayerCredits.Value = PlayerCredits.Value + Player.Character.Loot.Value
						game.ReplicatedStorage.Remotes.System:FireClient(Player,"StatChange",{"Credits",Player.Character.Loot.Value})
						local caculatedXP = Player.Character.Loot.Value * 0.1
						end
						game.ReplicatedStorage.Remotes.System:FireClient(Player,"StatChange",{"XP",caculatedXP})
						Player.PlayerData.PlayerXP.CurrentXP.Value = Player.PlayerData.PlayerXP.CurrentXP.Value + math.floor(caculatedXP)
						Player.Character.Loot:Destroy()
					end
--// Bank Setup
local BankDataValues = {Cooldown = false,InProgress = false,TimeLeft = 180}
local BankRegion = Regions.Bank
local BankZone = ZoneModule.new(BankRegion,14)
local VaultParts = workspace.BankParts

for _,v in pairs(VaultParts.VaultDoor:GetChildren()) do
	local newWeld = Instance.new("WeldConstraint")
	newWeld.Parent = VaultParts.Hinge
					newWeld.Part0 = VaultParts.Hinge
	newWeld.Part1 = v
	v.Anchored = false
end
for _,v in pairs(VaultParts.Lasers:GetChildren()) do
	local dmgTable = {}
	spawn(function()
		while true do
			TweenService:Create(v,TweenInfo.new(0.3,Enum.EasingStyle.Sine),{CFrame = v.CFrame * CFrame.new(0,v.Goal.Value,0)}):Play()
			wait(0.8)
			TweenService:Create(v,TweenInfo.new(0.3,Enum.EasingStyle.Sine),{CFrame = v.CFrame * CFrame.new(0,-v.Goal.Value,0)}):Play()
			wait(0.8)
		end
	end)
	v.Touched:Connect(function(Touch)
		local Humanoid = Touch.Parent:FindFirstChild("Humanoid") or Touch.Parent.Parent:FindFirstChild("Humanoid")
		if Humanoid then
			if not table.find(dmgTable,Humanoid.Parent.Name) then
				table.insert(dmgTable,1,Humanoid.Parent.Name)
				Humanoid:TakeDamage(47)
				delay(0.6,function()
					table.remove(dmgTable,table.find(dmgTable,Humanoid.Parent.Name))
				end)
			end
		end
	end)
end
local function tweenBankDoor(State)
	if State == "Open" then
		TweenService:Create(VaultParts.Hinge,TweenInfo.new(3,Enum.EasingStyle.Sine),{CFrame = VaultParts.Hinge.CFrame*CFrame.Angles(0,math.rad(100),0)}):Play()
	elseif State == "Close" then
		TweenService:Create(VaultParts.Hinge,TweenInfo.new(3,Enum.EasingStyle.Sine),{CFrame = VaultParts.Hinge.CFrame*CFrame.Angles(0,math.rad(-100),0)}):Play()
	end
end
local function startBankRob()
	local lastTick = tick()
	BankDataValues.TimeLeft = 90
	game.ReplicatedStorage.Remotes.System:FireAllClients("guiMessage",{"Bank Robbery","The Extrovian central bank is being robbed! Military personnel respond as soon as possible!",8})
	BankRegion.Detector.Alarm:Play()
	spawn(function()
		repeat wait(0.3)
			if tick()-lastTick >= 1 then
				BankDataValues.TimeLeft = BankDataValues.TimeLeft - 1
				lastTick = tick()
			end
			for _,Player in pairs(BankZone:getPlayers()) do
				if Player.Team ~= game.Teams["Falcon Imperium"] then
					if Player.Character:FindFirstChild("Loot") then
						if Player.Character.Loot.Value <= Player.Character.Loot.MaxLoot.Value then
							Player.Character.Loot.Value = Player.Character.Loot.Value + math.random(5,30)
							if Player.Character.Loot.Value > Player.Character.Loot.MaxLoot.Value then
								Player.Character.Loot.Value = Player.Character.Loot.MaxLoot.Value
							end
						end
					else
						makeLoot(Player)
					end
				end
			end
		until BankDataValues.TimeLeft <= 0
		for _,Player in pairs(BankZone:getPlayers()) do
			Player.Character.HumanoidRootPart.CFrame = workspace.TeleportPoints.BankPoint.CFrame
		end
		tweenBankDoor("Close")
		BankRegion.Detector.Alarm:Stop()
		BankDataValues.Cooldown = true
		BankDataValues.InProgress = false
		wait(300)
		local counter = 300
		if #game.Teams["Falcon Imperium"]:GetPlayers() >= 3 then
			BankDataValues.Cooldown = false
			tweenBankDoor("Open")
		else
			repeat wait(1)
				counter = counter - 1
			until #game.Teams["Falcon Imperium"]:GetPlayers() >= 3 or counter == 0
			BankDataValues.Cooldown = false
			tweenBankDoor("Open")
		end
	end)
end
BankZone.PlayerAdded:Connect(function(Player)
	if not BankDataValues.Cooldown and Player.Team ~= game.Teams["Falcon Imperium"] then
		if BankDataValues.InProgress then
			
		else
			BankDataValues.InProgress = true
			startBankRob()
		end
	end
end)

--// Jewelry Store
local JewelryDataValues = {Cooldown = false,InProgress = false,TimeLeft = 120}
local JewelryRegion = Regions["Jewelry Store"]
local JewelryZone = ZoneModule.new(JewelryRegion,45)
local JewelParts = workspace.JewelryParts

local function resetJewelStore()
	for _,Case in pairs(JewelParts.Cases:GetChildren()) do
		Case.Glass.CanCollide = true
		Case.Glass.Transparency = 0.7
		Case.BrokenCase.Value = false
		for _,Ring in pairs(Case.Rings:GetChildren()) do
			for _,Part in pairs(Ring.RingModel:GetChildren()) do
				Part.Transparency = 0
			end
		end
	end
end
local function tweenJewlDoor(State)
	if State == "Open" then
		TweenService:Create(JewelParts.MainDoor,TweenInfo.new(1.5,Enum.EasingStyle.Sine),{CFrame = JewelParts.MainDoor.CFrame*CFrame.new(0,24,0)}):Play()
	elseif State == "Close" then
		TweenService:Create(JewelParts.MainDoor,TweenInfo.new(0.9,Enum.EasingStyle.Sine),{CFrame = JewelParts.MainDoor.CFrame*CFrame.new(0,-24,0)}):Play()
	end
end
tweenJewlDoor("Open")
local function startJewelryRob()
	local lastTick = tick()
	JewelryDataValues.InProgress = true
	JewelryDataValues.TimeLeft = 180
	game.ReplicatedStorage.Remotes.System:FireAllClients("guiMessage",{"Store Robbery","The jewelry store is being robbed! Extrovian military personnel, respond as soon as you can.",7.5})
	JewelryRegion.Detector.Alarm:Play()
	tweenJewlDoor("Close")
	for _,Player in pairs(JewelryZone:getPlayers()) do
		if JewelryDataValues.InProgress then
			game.ReplicatedStorage.Remotes.System:FireClient(Player,"guiMessage",{"Game Help","You're robbing the jewelry store! Touch case glass to break it, then touch the rings to steal them! Make sure you escape before the time is up!",8})
		end
	end
	spawn(function()
		repeat wait(0.3)
			if tick()-lastTick >= 1 then
				JewelryDataValues.TimeLeft = JewelryDataValues.TimeLeft - 1
				lastTick = tick()
			end
		until JewelryDataValues.TimeLeft <= 0 or #JewelryZone:getPlayers() == 0
		for _,Player in pairs(JewelryZone:getPlayers()) do
			Player.Character.HumanoidRootPart.CFrame = workspace.TeleportPoints.JewelryPoint.CFrame
			if Player.Character:FindFirstChild("Loot") then
				Player.Character.Loot:Destroy()
			end
		end
		JewelryRegion.Detector.Alarm:Stop()
		JewelryDataValues.Cooldown = true
		JewelryDataValues.InProgress = false
		resetJewelStore()
		local cooldown = 300
		if #game.Teams["Falcon Imperium"]:GetPlayers() < 3 then
			cooldown = 600
		end
		delay(cooldown,function()
			JewelryDataValues.Cooldown = false
			tweenJewlDoor("Open")
		end)
	end)
end
game.ReplicatedStorage.Remotes.Binds.Jewelry.Event:Connect(function(Player,Request,Ring)
	if Request == "StealRing" then
		if JewelryDataValues.InProgress and not JewelryDataValues.Cooldown then
			local function safeCheck()
				if Player.Character:FindFirstChild("Loot") then
					if Player.Character.Loot.Value < Player.Character.Loot.MaxLoot.Value then
						return true
					else
						return false
					end
				else
					return true
				end
			end
			if table.find(JewelryZone:getPlayers(),Player) and safeCheck() then
				if not Player.Character:FindFirstChild("Loot") then
					makeLoot(Player)
				end
				Player.Team = game.Teams.Rebels
				game.ReplicatedStorage.Remotes.Binds.ApplyMorph:Fire("applyGamepass",{"Rebel",Player})
				game.ReplicatedStorage.Remotes.Binds.NameTag:Fire("setNametag",{"Rebels",Player})
				if Player.Character.Loot.Value < Player.Character.Loot.MaxLoot.Value then
					Player.Character.Loot.Value = Player.Character.Loot.Value + math.random(45,200)
				end
				if Player.Character.Loot.Value > Player.Character.Loot.MaxLoot.Value then
					Player.Character.Loot.Value = Player.Character.Loot.MaxLoot.Value
				end
				for _,v in pairs(Ring.RingModel:GetChildren()) do
					v.Transparency = 1 
				end
			end
		end
	end
end)
for _,Case in pairs(JewelParts.Cases:GetChildren()) do
	Case.Glass.Touched:Connect(function(Hit)
		local targetHumanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
		if targetHumanoid then
			local targetPlayer = game.Players:GetPlayerFromCharacter(targetHumanoid.Parent)
			if targetPlayer then
					if not JewelryDataValues.InProgress and not JewelryDataValues.Cooldown and not Case.BrokenCase.Value then
						startJewelryRob()
						Case.BrokenCase.Value = true
						Case.Glass.Transparency = 1
						Case.Glass.CanCollide = false
					elseif JewelryDataValues.InProgress and not JewelryDataValues.Cooldown and not Case.BrokenCase.Value then
						Case.BrokenCase.Value = true
						Case.Glass.Transparency = 1
						Case.Glass.CanCollide = false
					end
				end
			end
		end)
	end
end
JewelParts.JewelryVentHit.Touched:Connect(function(Hit)
	local targetHumanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
	if targetHumanoid then
		targetHumanoid.Parent.HumanoidRootPart.CFrame = workspace.TeleportPoints.JewelryPoint.CFrame
	end
end)
JewelryZone.PlayerAdded:Connect(function(Player)
		game.ReplicatedStorage.Remotes.System:FireClient(Player,"guiMessage",{"Game Help","You're robbing the jewelry store! Touch case glass to break it, then touch the rings to steal them! Make sure you escape before the time is up!",8})
	if not JewelryDataValues.InProgress and JewelryDataValues.Cooldown then
		Player.Character.HumanoidRootPart.CFrame = workspace.TeleportPoints.JewelryPoint.CFrame	
	end
end)
--// Loops
JewelryZone:initLoop(0.1)
BankZone:initLoop(0.1)


--// reminders
--warn("[ALERT]: JEWELRY STORE COOLDOWN SET TO 60 SECONDS FOR TESTING, SHOULD BE 300")
print("[Stage 2/nil] Loaded server "..script.Name.." ("..tick()-startTick..")")
1 Like
252                        end
253                  end) --Error
254	         end
255    end

if I had to guess

1 Like

Yes. but how can I fix the error?

1 Like

image
Do this. Tell me if anything else happens

1 Like

Nothing happens. Still gives me the same thing.

1 Like

You keep forgetting to close the function at line 20, you should add an end where that function is ending.

1 Like

An end is already added.

local function makeLoot(Player)
	if not Player.Character:FindFirstChild("Loot") and (Player.Team == game.Teams.Rebels or Player.Team == game.Teams.Citizens or tostring(Player.Team) == "Demolisher") then
		local newValue = Instance.new("NumberValue")
		newValue.Parent = Player.Character
		newValue.Name = "Loot"
		newValue.Value = 0
		local newMax = Instance.new("NumberValue")
		newMax.Parent = newValue
		newMax.Name = "MaxLoot"
		newMax.Value = 5000
	end	
end
for _,v in pairs(workspace.LootPoints:GetChildren()) do
	if v:IsA("Part") then
		v.Touched:Connect(function(Hit)
		end) -- Ending the function
1 Like
for _,v in pairs(workspace.LootPoints:GetChildren()) do
	if v:IsA("Part") then
		
		end -- Added 
	end -- Added
		v.Touched:Connect(function(Hit)
		end) -- This is the end of the function(Hit)
			local Humanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
			if Humanoid then
				local Player = game.Players:GetPlayerFromCharacter(Humanoid.Parent)
				if Player then
					if Player.Character:FindFirstChild("Loot") then
						local PlayerCredits = Player:WaitForChild("PlayerData"):WaitForChild("Credits")
						PlayerCredits.Value = PlayerCredits.Value + Player.Character.Loot.Value
						game.ReplicatedStorage.Remotes.System:FireClient(Player,"StatChange",{"Credits",Player.Character.Loot.Value})
						local caculatedXP = Player.Character.Loot.Value * 0.1
						end
						game.ReplicatedStorage.Remotes.System:FireClient(Player,"StatChange",{"XP",caculatedXP})
						Player.PlayerData.PlayerXP.CurrentXP.Value = Player.PlayerData.PlayerXP.CurrentXP.Value + math.floor(caculatedXP)
						Player.Character.Loot:Destroy()
					end

the script stopped showing errors, but that function is empty

1 Like

I did temporary variables (everything set to 1), and there isn’t an error.

print("[Stage 2/nil] Loading server "..script.Name);local startTick = tick()
local ZoneModule = require(4958963725)
local Regions = workspace.Regions
local TweenService = game:GetService("TweenService")
local Hit = 1
local caculatedXP = 09
local function makeLoot(Player)
	if not Player.Character:FindFirstChild("Loot") and (Player.Team == game.Teams.Rebels or Player.Team == game.Teams.Citizens or tostring(Player.Team) == "Demolisher") then
		local newValue = Instance.new("NumberValue")
		newValue.Parent = Player.Character
		newValue.Name = "Loot"
		newValue.Value = 0
		local newMax = Instance.new("NumberValue")
		newMax.Parent = newValue
		newMax.Name = "MaxLoot"
		newMax.Value = 5000
	end	
end
for _,v in pairs(workspace.LootPoints:GetChildren()) do
	if v:IsA("Part") then
		v.Touched:Connect(function(Hit)
		end)
		local Humanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
		if Humanoid then
			local Player = game.Players:GetPlayerFromCharacter(Humanoid.Parent)
			if Player then
				if Player.Character:FindFirstChild("Loot") then
					local PlayerCredits = Player:WaitForChild("PlayerData"):WaitForChild("Credits")
					PlayerCredits.Value = PlayerCredits.Value + Player.Character.Loot.Value
					game.ReplicatedStorage.Remotes.System:FireClient(Player,"StatChange",{"Credits",Player.Character.Loot.Value})
					local caculatedXP = Player.Character.Loot.Value * 0.1
				end
				game.ReplicatedStorage.Remotes.System:FireClient(Player,"StatChange",{"XP",caculatedXP})
				Player.PlayerData.PlayerXP.CurrentXP.Value = Player.PlayerData.PlayerXP.CurrentXP.Value + math.floor(caculatedXP)
				Player.Character.Loot:Destroy()
			end
			--// Bank Setup
			local BankDataValues = {Cooldown = false,InProgress = false,TimeLeft = 180}
			local BankRegion = Regions.Bank
			local BankZone = ZoneModule.new(BankRegion,14)
			local VaultParts = workspace.BankParts

			for _,v in pairs(VaultParts.VaultDoor:GetChildren()) do
				local newWeld = Instance.new("WeldConstraint")
				newWeld.Parent = VaultParts.Hinge
				newWeld.Part0 = VaultParts.Hinge
				newWeld.Part1 = v
				v.Anchored = false
			end
			for _,v in pairs(VaultParts.Lasers:GetChildren()) do
				local dmgTable = {}
				spawn(function()
					while true do
						TweenService:Create(v,TweenInfo.new(0.3,Enum.EasingStyle.Sine),{CFrame = v.CFrame * CFrame.new(0,v.Goal.Value,0)}):Play()
						wait(0.8)
						TweenService:Create(v,TweenInfo.new(0.3,Enum.EasingStyle.Sine),{CFrame = v.CFrame * CFrame.new(0,-v.Goal.Value,0)}):Play()
						wait(0.8)
					end
				end)
				v.Touched:Connect(function(Touch)
					local Humanoid = Touch.Parent:FindFirstChild("Humanoid") or Touch.Parent.Parent:FindFirstChild("Humanoid")
					if Humanoid then
						if not table.find(dmgTable,Humanoid.Parent.Name) then
							table.insert(dmgTable,1,Humanoid.Parent.Name)
							Humanoid:TakeDamage(47)
							delay(0.6,function()
								table.remove(dmgTable,table.find(dmgTable,Humanoid.Parent.Name))
							end)
						end
					end
				end)
			end
			local function tweenBankDoor(State)
				if State == "Open" then
					TweenService:Create(VaultParts.Hinge,TweenInfo.new(3,Enum.EasingStyle.Sine),{CFrame = VaultParts.Hinge.CFrame*CFrame.Angles(0,math.rad(100),0)}):Play()
				elseif State == "Close" then
					TweenService:Create(VaultParts.Hinge,TweenInfo.new(3,Enum.EasingStyle.Sine),{CFrame = VaultParts.Hinge.CFrame*CFrame.Angles(0,math.rad(-100),0)}):Play()
				end
			end
			local function startBankRob()
				local lastTick = tick()
				BankDataValues.TimeLeft = 90
				game.ReplicatedStorage.Remotes.System:FireAllClients("guiMessage",{"Bank Robbery","The Extrovian central bank is being robbed! Military personnel respond as soon as possible!",8})
				BankRegion.Detector.Alarm:Play()
				spawn(function()
					repeat wait(0.3)
						if tick()-lastTick >= 1 then
							BankDataValues.TimeLeft = BankDataValues.TimeLeft - 1
							lastTick = tick()
						end
						for _,Player in pairs(BankZone:getPlayers()) do
							if Player.Team ~= game.Teams["Falcon Imperium"] then
								if Player.Character:FindFirstChild("Loot") then
									if Player.Character.Loot.Value <= Player.Character.Loot.MaxLoot.Value then
										Player.Character.Loot.Value = Player.Character.Loot.Value + math.random(5,30)
										if Player.Character.Loot.Value > Player.Character.Loot.MaxLoot.Value then
											Player.Character.Loot.Value = Player.Character.Loot.MaxLoot.Value
										end
									end
								else
									makeLoot(Player)
								end
							end
						end
					until BankDataValues.TimeLeft <= 0
					for _,Player in pairs(BankZone:getPlayers()) do
						Player.Character.HumanoidRootPart.CFrame = workspace.TeleportPoints.BankPoint.CFrame
					end
					tweenBankDoor("Close")
					BankRegion.Detector.Alarm:Stop()
					BankDataValues.Cooldown = true
					BankDataValues.InProgress = false
					wait(300)
					local counter = 300
					if #game.Teams["Falcon Imperium"]:GetPlayers() >= 3 then
						BankDataValues.Cooldown = false
						tweenBankDoor("Open")
					else
						repeat wait(1)
							counter = counter - 1
						until #game.Teams["Falcon Imperium"]:GetPlayers() >= 3 or counter == 0
						BankDataValues.Cooldown = false
						tweenBankDoor("Open")
					end
				end)
			end
			BankZone.PlayerAdded:Connect(function(Player)
				if not BankDataValues.Cooldown and Player.Team ~= game.Teams["Falcon Imperium"] then
					if BankDataValues.InProgress then

					else
						BankDataValues.InProgress = true
						startBankRob()
					end
				end
			end)

			--// Jewelry Store
			local JewelryDataValues = {Cooldown = false,InProgress = false,TimeLeft = 120}
			local JewelryRegion = Regions["Jewelry Store"]
			local JewelryZone = ZoneModule.new(JewelryRegion,45)
			local JewelParts = workspace.JewelryParts

			local function resetJewelStore()
				for _,Case in pairs(JewelParts.Cases:GetChildren()) do
					Case.Glass.CanCollide = true
					Case.Glass.Transparency = 0.7
					Case.BrokenCase.Value = false
					for _,Ring in pairs(Case.Rings:GetChildren()) do
						for _,Part in pairs(Ring.RingModel:GetChildren()) do
							Part.Transparency = 0
						end
					end
				end
			end
			local function tweenJewlDoor(State)
				if State == "Open" then
					TweenService:Create(JewelParts.MainDoor,TweenInfo.new(1.5,Enum.EasingStyle.Sine),{CFrame = JewelParts.MainDoor.CFrame*CFrame.new(0,24,0)}):Play()
				elseif State == "Close" then
					TweenService:Create(JewelParts.MainDoor,TweenInfo.new(0.9,Enum.EasingStyle.Sine),{CFrame = JewelParts.MainDoor.CFrame*CFrame.new(0,-24,0)}):Play()
				end
			end
			tweenJewlDoor("Open")
			local function startJewelryRob()
				local lastTick = tick()
				JewelryDataValues.InProgress = true
				JewelryDataValues.TimeLeft = 180
				game.ReplicatedStorage.Remotes.System:FireAllClients("guiMessage",{"Store Robbery","The jewelry store is being robbed! Extrovian military personnel, respond as soon as you can.",7.5})
				JewelryRegion.Detector.Alarm:Play()
				tweenJewlDoor("Close")
				for _,Player in pairs(JewelryZone:getPlayers()) do
					if JewelryDataValues.InProgress then
						game.ReplicatedStorage.Remotes.System:FireClient(Player,"guiMessage",{"Game Help","You're robbing the jewelry store! Touch case glass to break it, then touch the rings to steal them! Make sure you escape before the time is up!",8})
					end
				end
				spawn(function()
					repeat wait(0.3)
						if tick()-lastTick >= 1 then
							JewelryDataValues.TimeLeft = JewelryDataValues.TimeLeft - 1
							lastTick = tick()
						end
					until JewelryDataValues.TimeLeft <= 0 or #JewelryZone:getPlayers() == 0
					for _,Player in pairs(JewelryZone:getPlayers()) do
						Player.Character.HumanoidRootPart.CFrame = workspace.TeleportPoints.JewelryPoint.CFrame
						if Player.Character:FindFirstChild("Loot") then
							Player.Character.Loot:Destroy()
						end
					end
					JewelryRegion.Detector.Alarm:Stop()
					JewelryDataValues.Cooldown = true
					JewelryDataValues.InProgress = false
					resetJewelStore()
					local cooldown = 300
					if #game.Teams["Falcon Imperium"]:GetPlayers() < 3 then
						cooldown = 600
					end
					delay(cooldown,function()
						JewelryDataValues.Cooldown = false
						tweenJewlDoor("Open")
					end)
				end)
			end
			game.ReplicatedStorage.Remotes.Binds.Jewelry.Event:Connect(function(Player,Request,Ring)
				if Request == "StealRing" then
					if JewelryDataValues.InProgress and not JewelryDataValues.Cooldown then
						local function safeCheck()
							if Player.Character:FindFirstChild("Loot") then
								if Player.Character.Loot.Value < Player.Character.Loot.MaxLoot.Value then
									return true
								else
									return false
								end
							else
								return true
							end
						end
						if table.find(JewelryZone:getPlayers(),Player) and safeCheck() then
							if not Player.Character:FindFirstChild("Loot") then
								makeLoot(Player)
							end
							Player.Team = game.Teams.Rebels
							game.ReplicatedStorage.Remotes.Binds.ApplyMorph:Fire("applyGamepass",{"Rebel",Player})
							game.ReplicatedStorage.Remotes.Binds.NameTag:Fire("setNametag",{"Rebels",Player})
							if Player.Character.Loot.Value < Player.Character.Loot.MaxLoot.Value then
								Player.Character.Loot.Value = Player.Character.Loot.Value + math.random(45,200)
							end
							if Player.Character.Loot.Value > Player.Character.Loot.MaxLoot.Value then
								Player.Character.Loot.Value = Player.Character.Loot.MaxLoot.Value
							end
							for _,v in pairs(Ring.RingModel:GetChildren()) do
								v.Transparency = 1 
							end
						end
					end
				end
			end)
			for _,Case in pairs(JewelParts.Cases:GetChildren()) do
				Case.Glass.Touched:Connect(function(Hit)
					local targetHumanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
					if targetHumanoid then
						local targetPlayer = game.Players:GetPlayerFromCharacter(targetHumanoid.Parent)
						if targetPlayer then
							if not JewelryDataValues.InProgress and not JewelryDataValues.Cooldown and not Case.BrokenCase.Value then
								startJewelryRob()
								Case.BrokenCase.Value = true
								Case.Glass.Transparency = 1
								Case.Glass.CanCollide = false
							elseif JewelryDataValues.InProgress and not JewelryDataValues.Cooldown and not Case.BrokenCase.Value then
								Case.BrokenCase.Value = true
								Case.Glass.Transparency = 1
								Case.Glass.CanCollide = false
							end
						end
					end
				end)
			end
		end
		local JewelParts = 1
		local JewelryDataValues = 1
		local JewelryZone = 1
		JewelParts.JewelryVentHit.Touched:Connect(function(Hit)
			local targetHumanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
			if targetHumanoid then
				targetHumanoid.Parent.HumanoidRootPart.CFrame = workspace.TeleportPoints.JewelryPoint.CFrame
			end
		end)
		JewelryZone.PlayerAdded:Connect(function(Player)
			game.ReplicatedStorage.Remotes.System:FireClient(Player,"guiMessage",{"Game Help","You're robbing the jewelry store! Touch case glass to break it, then touch the rings to steal them! Make sure you escape before the time is up!",8})
			if not JewelryDataValues.InProgress and JewelryDataValues.Cooldown then
				Player.Character.HumanoidRootPart.CFrame = workspace.TeleportPoints.JewelryPoint.CFrame	
			end
		end)
		--// Loops
		JewelryZone:initLoop(0.1)
		BankZone:initLoop(0.1)
	end
	end

		--// reminders
		--warn("[ALERT]: JEWELRY STORE COOLDOWN SET TO 60 SECONDS FOR TESTING, SHOULD BE 300")
		print("[Stage 2/nil] Loaded server "..script.Name.." ("..tick()-startTick..")")
		

In my code, ignore this stuff, it’s to stopp Unknown Global errors
local Hit = 1
local caculatedXP = 09
|||local JewelParts = 1
|||local JewelryDataValues = 1
|||local JewelryZone = 1

1 Like

I copied down your version of the script, and it gave me a new error.
https://gyazo.com/ea6b78bba377b99c89370d5c294ab030

1 Like

i see alot of errors in your script, i’m trying to fix it

Some functions are using a variable, and you place an end in the next line

that will make the variable useless, and the appearance of the ''Yellow marks" lined on them

Press Control Z, and make sure you are defining JewelryZone, JewelryDataValues, JewelParts, JewelParts, BankZone, and Hit.

Everything is good except for the starting of the script.

if not Player.Character:FindFirstChild("Loot") and (Player.Team == game.Teams.Rebels or Player.Team == game.Teams.Citizens or tostring(Player.Team) == "Demolisher") then
	local newValue = Instance.new("NumberValue")
	newValue.Parent = Player.Character
	newValue.Name = "Loot"
	newValue.Value = 0
	local newMax = Instance.new("NumberValue")
	newMax.Parent = newValue
	newMax.Name = "MaxLoot"
	newMax.Value = 5000
	end	
end -- error is in this now giving a few lines a yellow underline

Does this work?

Script
print("[Stage 2/nil] Loading server "..script.Name);local startTick = tick()
local ZoneModule = require(4958963725)
local Regions = workspace.Regions
local TweenService = game:GetService("TweenService")

local function makeLoot(Player)
	if not Player.Character:FindFirstChild("Loot") and (Player.Team == game.Teams.Rebels or Player.Team == game.Teams.Citizens or tostring(Player.Team) == "Demolisher") then
		local newValue = Instance.new("NumberValue")
		newValue.Parent = Player.Character
		newValue.Name = "Loot"
		newValue.Value = 0
		local newMax = Instance.new("NumberValue")
		newMax.Parent = newValue
		newMax.Name = "MaxLoot"
		newMax.Value = 5000
	end	
end
for _,v in pairs(workspace.LootPoints:GetChildren()) do
	if v:IsA("Part") then
		v.Touched:Connect(function(Hit)
			local Humanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
			if Humanoid then
				local Player = game.Players:GetPlayerFromCharacter(Humanoid.Parent)
				if Player then
					if Player.Character:FindFirstChild("Loot") then
						local PlayerCredits = Player:WaitForChild("PlayerData"):WaitForChild("Credits")
						PlayerCredits.Value = PlayerCredits.Value + Player.Character.Loot.Value
						game.ReplicatedStorage.Remotes.System:FireClient(Player,"StatChange",{"Credits",Player.Character.Loot.Value})
						local caculatedXP = Player.Character.Loot.Value * 0.1
					end
					game.ReplicatedStorage.Remotes.System:FireClient(Player,"StatChange",{"XP",caculatedXP})
					Player.PlayerData.PlayerXP.CurrentXP.Value = Player.PlayerData.PlayerXP.CurrentXP.Value + math.floor(caculatedXP)
					Player.Character.Loot:Destroy()
				end
				--// Bank Setup
				local BankDataValues = {Cooldown = false,InProgress = false,TimeLeft = 180}
				local BankRegion = Regions.Bank
				local BankZone = ZoneModule.new(BankRegion,14)
				local VaultParts = workspace.BankParts
	
				for _,v in pairs(VaultParts.VaultDoor:GetChildren()) do
					local newWeld = Instance.new("WeldConstraint")
					newWeld.Parent = VaultParts.Hinge
					newWeld.Part0 = VaultParts.Hinge
					newWeld.Part1 = v
					v.Anchored = false
				end
				for _,v in pairs(VaultParts.Lasers:GetChildren()) do
					local dmgTable = {}
					spawn(function()
						while true do
							TweenService:Create(v,TweenInfo.new(0.3,Enum.EasingStyle.Sine),{CFrame = v.CFrame * CFrame.new(0,v.Goal.Value,0)}):Play()
							wait(0.8)
							TweenService:Create(v,TweenInfo.new(0.3,Enum.EasingStyle.Sine),{CFrame = v.CFrame * CFrame.new(0,-v.Goal.Value,0)}):Play()
							wait(0.8)
						end
					end)
					v.Touched:Connect(function(Touch)
						local Humanoid = Touch.Parent:FindFirstChild("Humanoid") or Touch.Parent.Parent:FindFirstChild("Humanoid")
						if Humanoid then
							if not table.find(dmgTable,Humanoid.Parent.Name) then
								table.insert(dmgTable,1,Humanoid.Parent.Name)
								Humanoid:TakeDamage(47)
								delay(0.6,function()
									table.remove(dmgTable,table.find(dmgTable,Humanoid.Parent.Name))
								end)
							end
						end
					end)
				end
				local function tweenBankDoor(State)
					if State == "Open" then
						TweenService:Create(VaultParts.Hinge,TweenInfo.new(3,Enum.EasingStyle.Sine),{CFrame = VaultParts.Hinge.CFrame*CFrame.Angles(0,math.rad(100),0)}):Play()
					elseif State == "Close" then
						TweenService:Create(VaultParts.Hinge,TweenInfo.new(3,Enum.EasingStyle.Sine),{CFrame = VaultParts.Hinge.CFrame*CFrame.Angles(0,math.rad(-100),0)}):Play()
					end
				end
				local function startBankRob()
					local lastTick = tick()
					BankDataValues.TimeLeft = 90
					game.ReplicatedStorage.Remotes.System:FireAllClients("guiMessage",{"Bank Robbery","The Extrovian central bank is being robbed! Military personnel respond as soon as possible!",8})
					BankRegion.Detector.Alarm:Play()
					spawn(function()
						repeat wait(0.3)
							if tick()-lastTick >= 1 then
								BankDataValues.TimeLeft = BankDataValues.TimeLeft - 1
								lastTick = tick()
							end
							for _,Player in pairs(BankZone:getPlayers()) do
								if Player.Team ~= game.Teams["Falcon Imperium"] then
									if Player.Character:FindFirstChild("Loot") then
										if Player.Character.Loot.Value <= Player.Character.Loot.MaxLoot.Value then
											Player.Character.Loot.Value = Player.Character.Loot.Value + math.random(5,30)
											if Player.Character.Loot.Value > Player.Character.Loot.MaxLoot.Value then
												Player.Character.Loot.Value = Player.Character.Loot.MaxLoot.Value
											end
										end
									else
										makeLoot(Player)
									end
								end
							end
						until BankDataValues.TimeLeft <= 0
						for _,Player in pairs(BankZone:getPlayers()) do
							Player.Character.HumanoidRootPart.CFrame = workspace.TeleportPoints.BankPoint.CFrame
						end
						tweenBankDoor("Close")
						BankRegion.Detector.Alarm:Stop()
						BankDataValues.Cooldown = true
						BankDataValues.InProgress = false
						wait(300)
						local counter = 300
						if #game.Teams["Falcon Imperium"]:GetPlayers() >= 3 then
							BankDataValues.Cooldown = false
							tweenBankDoor("Open")
						else
							repeat wait(1)
								counter = counter - 1
							until #game.Teams["Falcon Imperium"]:GetPlayers() >= 3 or counter == 0
							BankDataValues.Cooldown = false
							tweenBankDoor("Open")
						end
					end)
				end
				BankZone.PlayerAdded:Connect(function(Player)
					if not BankDataValues.Cooldown and Player.Team ~= game.Teams["Falcon Imperium"] then
						if BankDataValues.InProgress then
	
						else
							BankDataValues.InProgress = true
							startBankRob()
						end
					end
				end)
	
				--// Jewelry Store
				local JewelryDataValues = {Cooldown = false,InProgress = false,TimeLeft = 120}
				local JewelryRegion = Regions["Jewelry Store"]
				local JewelryZone = ZoneModule.new(JewelryRegion,45)
				local JewelParts = workspace.JewelryParts
	
				local function resetJewelStore()
					for _,Case in pairs(JewelParts.Cases:GetChildren()) do
						Case.Glass.CanCollide = true
						Case.Glass.Transparency = 0.7
						Case.BrokenCase.Value = false
						for _,Ring in pairs(Case.Rings:GetChildren()) do
							for _,Part in pairs(Ring.RingModel:GetChildren()) do
								Part.Transparency = 0
							end
						end
					end
				end
				local function tweenJewlDoor(State)
					if State == "Open" then
						TweenService:Create(JewelParts.MainDoor,TweenInfo.new(1.5,Enum.EasingStyle.Sine),{CFrame = JewelParts.MainDoor.CFrame*CFrame.new(0,24,0)}):Play()
					elseif State == "Close" then
						TweenService:Create(JewelParts.MainDoor,TweenInfo.new(0.9,Enum.EasingStyle.Sine),{CFrame = JewelParts.MainDoor.CFrame*CFrame.new(0,-24,0)}):Play()
					end
				end
				tweenJewlDoor("Open")
				local function startJewelryRob()
					local lastTick = tick()
					JewelryDataValues.InProgress = true
					JewelryDataValues.TimeLeft = 180
					game.ReplicatedStorage.Remotes.System:FireAllClients("guiMessage",{"Store Robbery","The jewelry store is being robbed! Extrovian military personnel, respond as soon as you can.",7.5})
					JewelryRegion.Detector.Alarm:Play()
					tweenJewlDoor("Close")
					for _,Player in pairs(JewelryZone:getPlayers()) do
						if JewelryDataValues.InProgress then
							game.ReplicatedStorage.Remotes.System:FireClient(Player,"guiMessage",{"Game Help","You're robbing the jewelry store! Touch case glass to break it, then touch the rings to steal them! Make sure you escape before the time is up!",8})
						end
					end
					spawn(function()
						repeat wait(0.3)
							if tick()-lastTick >= 1 then
								JewelryDataValues.TimeLeft = JewelryDataValues.TimeLeft - 1
								lastTick = tick()
							end
						until JewelryDataValues.TimeLeft <= 0 or #JewelryZone:getPlayers() == 0
						for _,Player in pairs(JewelryZone:getPlayers()) do
							Player.Character.HumanoidRootPart.CFrame = workspace.TeleportPoints.JewelryPoint.CFrame
							if Player.Character:FindFirstChild("Loot") then
								Player.Character.Loot:Destroy()
							end
						end
						JewelryRegion.Detector.Alarm:Stop()
						JewelryDataValues.Cooldown = true
						JewelryDataValues.InProgress = false
						resetJewelStore()
						local cooldown = 300
						if #game.Teams["Falcon Imperium"]:GetPlayers() < 3 then
							cooldown = 600
						end
						delay(cooldown,function()
							JewelryDataValues.Cooldown = false
							tweenJewlDoor("Open")
						end)
					end)
				end
				game.ReplicatedStorage.Remotes.Binds.Jewelry.Event:Connect(function(Player,Request,Ring)
					if Request == "StealRing" then
						if JewelryDataValues.InProgress and not JewelryDataValues.Cooldown then
							local function safeCheck()
								if Player.Character:FindFirstChild("Loot") then
									if Player.Character.Loot.Value < Player.Character.Loot.MaxLoot.Value then
										return true
									else
										return false
									end
								else
									return true
								end
							end
							if table.find(JewelryZone:getPlayers(),Player) and safeCheck() then
								if not Player.Character:FindFirstChild("Loot") then
									makeLoot(Player)
								end
								Player.Team = game.Teams.Rebels
								game.ReplicatedStorage.Remotes.Binds.ApplyMorph:Fire("applyGamepass",{"Rebel",Player})
								game.ReplicatedStorage.Remotes.Binds.NameTag:Fire("setNametag",{"Rebels",Player})
								if Player.Character.Loot.Value < Player.Character.Loot.MaxLoot.Value then
									Player.Character.Loot.Value = Player.Character.Loot.Value + math.random(45,200)
								end
								if Player.Character.Loot.Value > Player.Character.Loot.MaxLoot.Value then
									Player.Character.Loot.Value = Player.Character.Loot.MaxLoot.Value
								end
								for _,v in pairs(Ring.RingModel:GetChildren()) do
									v.Transparency = 1 
								end
							end
						end
					end
				end)
				for _,Case in pairs(JewelParts.Cases:GetChildren()) do
					Case.Glass.Touched:Connect(function(Hit)
						local targetHumanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
						if targetHumanoid then
							local targetPlayer = game.Players:GetPlayerFromCharacter(targetHumanoid.Parent)
							if targetPlayer then
								if not JewelryDataValues.InProgress and not JewelryDataValues.Cooldown and not Case.BrokenCase.Value then
									startJewelryRob()
									Case.BrokenCase.Value = true
									Case.Glass.Transparency = 1
									Case.Glass.CanCollide = false
								elseif JewelryDataValues.InProgress and not JewelryDataValues.Cooldown and not Case.BrokenCase.Value then
									Case.BrokenCase.Value = true
									Case.Glass.Transparency = 1
									Case.Glass.CanCollide = false
								end
							end
						end
					end)
				end
				JewelParts.JewelryVentHit.Touched:Connect(function(Hit)
					local targetHumanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
					if targetHumanoid then
						targetHumanoid.Parent.HumanoidRootPart.CFrame = workspace.TeleportPoints.JewelryPoint.CFrame
					end
				end)
				JewelryZone.PlayerAdded:Connect(function(Player)
					game.ReplicatedStorage.Remotes.System:FireClient(Player,"guiMessage",{"Game Help","You're robbing the jewelry store! Touch case glass to break it, then touch the rings to steal them! Make sure you escape before the time is up!",8})
					if not JewelryDataValues.InProgress and JewelryDataValues.Cooldown then
						Player.Character.HumanoidRootPart.CFrame = workspace.TeleportPoints.JewelryPoint.CFrame	
					end
				end)
				
				--// Loops
				JewelryZone:initLoop(0.1)
				BankZone:initLoop(0.1)
			end
		end)
	end
end	

--// reminders
--warn("[ALERT]: JEWELRY STORE COOLDOWN SET TO 60 SECONDS FOR TESTING, SHOULD BE 300")
print("[Stage 2/nil] Loaded server "..script.Name.." ("..tick()-startTick..")")
1 Like
local Player = game.Players.LocalPlayer
if not Player.Character:FindFirstChild("Loot") and (Player.Team == game.Teams.Rebels or Player.Team == game.Teams.Citizens or tostring(Player.Team) == "Demolisher") then
	local newValue = Instance.new("NumberValue")
	newValue.Parent = Player.Character
	newValue.Name = "Loot"
	newValue.Value = 0
	local newMax = Instance.new("NumberValue")
	newMax.Parent = newValue
	newMax.Name = "MaxLoot"
	newMax.Value = 5000
end