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 ?