Economy x Bank Robbery System - Proximity Prompts not working
I am working on a secure Economy System with a Bank Robbery System. I have first worked with a base where I only created random sized blocks which were dropped into workspace.
I changed to a bank steal objets system with permanent positions but not anchored, it broke fully. It doesn’t show the proximity prompts anymore.
I tried fix it with Hitboxes, it worked for 4 cash blocks in the middle of the room when I am over them standing.
This is the drop cash/gold bars block script which does for each item in BankDrops Folder, which is located in ServerStorage, to get the object, clone it and add a proximity prompt. I have for the gold bars specific values and for the cash blocks it are random Values. Everything works except the Proximity Prompt not showing. The function for proximity prompt triggered works.
local function generateCash(Part, Id, Value)
local originalName = Part.Name
local item = Part:Clone()--CashBagTemplate:Clone() --Instance.new("Part")
item.Name = Id
--cash.Size = Vector3.new(2, 2, 2)
--cash.PrimaryPart.CFrame = CFrame.new(math.random(-5,5), 15, math.random(-5,5)) --Vector3.new(math.random(-5,5), 15, math.random(-5,5)) -- Change to Bank location
--cash.BrickColor = BrickColor.new("Bright yellow")
--cash.Material = Enum.Material.Neon
--cash.Transparency = 0
--cash.CanCollide = false
item.Hitbox.Transparency = 1;
local pp = Instance.new("ProximityPrompt")
pp.Parent = item.Hitbox
item.Hitbox.Name = Id
pp.Name = Id
pp.ObjectText = "Steal"
pp.ActionText = "Hold [E] to interact"
pp.Triggered:Connect(function(player)
pp.Enabled = false
local profile = getProfile(player)
if profile then
if cashTable[pp.Name] then
local cashValue = cashTable[pp.Name]
profile.Data.Cash = profile.Data.Cash + cashValue
Robberys[player.UserId]["Reward"] = Robberys[player.UserId]["Reward"] + cashValue
cashTable[pp.Name] = nil
Save(player, profile)
pp.Parent.Parent:Destroy()
else
player:Kick("Anti-Cheat:\nYou have been kicked by the Anti Cheat!\n\nReason:\nCash Duplication Detected")
end
end
end)
if string.find(originalName, "Normal") then
item.Parent = workspace.Bank.Drops.Normal
elseif string.find(originalName, "Case") then
item.Parent = workspace.Bank.Drops.Cases
elseif string.find(originalName, "Cart") then
item.Parent = workspace.Bank.Drops.Carts
end
end
function dropCash()
for _, object in pairs(BankDrops:GetChildren()) do
local CashId = generateCashId()
local CashValue;
if string.find(object.Name, "Normal") then
if string.find(object.Name, "Gold") then
CashValue = 7500
elseif string.find(object.Name, "Cash") then
CashValue = math.random(750, 1500)
end
elseif string.find(object.Name, "Case") then
if string.find(object.Name, "Gold") then
CashValue = 1250
elseif string.find(object.Name, "Cash") then
CashValue = math.random(250, 800)
end
elseif string.find(object.Name, "Cart") then
if string.find(object.Name, "Gold") then
CashValue = 7500
elseif string.find(object.Name, "Cash") then
CashValue = math.random(750, 1500)
end
end
cashTable[CashId] = CashValue
local NewDrop = generateCash(object, CashId, CashValue)
end
end