Help the scripts dont work for the Robbable bank

So I am trying to make a robbable bank for my game, but I did it all from Noobie on youtube but when I finished it, it said this… [ - Script ‘Workspace.Scripts.MoneyGiver’, Line 31 - function GetPlayersInPart]
I ll show the script which is called money giver…

local Debounce = false
local PlayerFound = false
function CreateRegion3FromPart(Part)
return Region3.new(Part.Position-(Part.Size/2),Part.Position+(Part.Size/2))
end

function GetPlayersInPart(Part)
local region = CreateRegion3FromPart(Part)
local partsInRegion = workspace:FindPartsInRegion3(region,nil,math.huge)
local Players = {}

for i, Part in pairs(PartsInRegion) do
	local player = game.Players:GetPlayerFromCharacter(Part.Parent)
	if player then
		
		for i, v in pairs(Players) do
			if Players[i].Name == player.Name then
				PlayerFound = true
	
			end
		end
		
		if PlayerFound == false then
			table.insert(Players,player)
		end
		PlayerFound = false
	end
end

for i, v in pairs(Players) do
 if Players[i].Robbing.Value == false then
		game.ReplicatedStorage.ShowMoneyGui:FireClient(Players[i])
	end
	Players[i].Robbing.Value = true
	if Players[i].CashCollected.Value < 5000 then
		Players[i].CashCollected.Value = Players[i].CashCollected.Value + 100
	end
end
return Players

end

while wait(0.5) do
GetPlayersInPart(game.Workspace.BankDetector)
end

then I put a part where you collect cash and the script is this…

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.Robbing.Value == true then
game.ReplicatedStorage.HideMoneyGui:FireClient(player)
player.leaderstats.Money.Value = player.leaderstats.Money.Value + player.CashCollected.Value

		player.CashCollected = 0
		player.Robbing.Value = false
	end
end

end)

Can someone help me please ?

3 Likes

What is the exact error you are getting?

[Script ‘Workspace.Scripts.MoneyGiver’, Line 31 - function GetPlayersInPart] And

[Script ‘Workspace.Scripts.MoneyGiver’, Line 43]

This is what it showed at the output.

I dont know what i did wrong in the script !

That’s not the error. It’s the script where the error was found. What is the full message that the output shows?

I dont get what you mean but if I copy paste it will give this…

14:15:27.929 - Script ‘Workspace.Scripts.MoneyGiver’, Line 43

14:15:27.928 - Script ‘Workspace.Scripts.MoneyGiver’, Line 31 - function GetPlayersInPart

Can you send a screenshot of the error? (including the red part)

Yes I will right now :smiley: !

1 Like

Sorry but On my PC I do not have the option to screenshot so I did from my phone sorry.

This is the output.

Ah, I see. Basically the value Robbing is not in the player. Can you show me the leaderstats script?

Click on the red error to see what part of what script it brings you to.

EDIT: Bpilot beat me to asking

I will right now :smiley: !
Just wait a few minutes :smiley:

1 Like

Ok I will just wait pkease :smiley:

bro you dont set the parent of robbing

Use :WaitForChild method.

player:WaitForChild("Robbing").Value = false

Test it, and see what you got.

Here !

Ok but in what script tho :smiley:

Leaderstats script. That one you posted where the error line bring you.