What do you want to achieve?
If the player is on the criminal team and they trigger the proximity prompt, they will get money,
What is the issue?
Whenever the player escapes jail and becomes a criminal, it’ll automatically give them the money from the robbery.
What solutions have you tried so far?
I see the problem, I have it down as “if player.Team.Name == criminal then”, automatically giving them the money, but I have it in the proximity prompt stuff so idk how to fix it cause it should be only giving it to them if they triggered the proximity prompt.
local pps = game:GetService("ProximityPromptService")
local canrob = true
pps.PromptTriggered:Connect(function(pp, plr)
if canrob == true then
if plr.Team.Name == "Criminal" then
local randomCash = math.random(50, 250)
plr.leaderstats.Cash.Value += randomCash
plr.leaderstats.Bounty.Value += 100
canrob = false
plr.PlayerGui.StoreRobbed.Enabled = true
plr.PlayerGui.StoreRobbed.Frame.CashAmount.Text = randomCash
script.Money:Play()
wait(3)
plr.PlayerGui.StoreRobbed.Enabled = false
else
plr.leaderstats.Cash.Value += 0
plr.leaderstats.Bounty.Value += 0
end
else
plr.leaderstats.Cash.Value += 0
plr.leaderstats.Bounty.Value += 0
end
end)
while true do
wait(300)
canrob = true
end
You forgot to check what prompt was triggered, also you don’t need to use ProximityPromptService for this, rather just do script.Parent.Triggered, change your script to:
local canrob = true
script.Parent.Triggered:Connect(function(plr)
if canrob == true then
if plr.Team.Name == "Criminal" then
local randomCash = math.random(50, 250)
plr.leaderstats.Cash.Value += randomCash
plr.leaderstats.Bounty.Value += 100
canrob = false
plr.PlayerGui.StoreRobbed.Enabled = true
plr.PlayerGui.StoreRobbed.Frame.CashAmount.Text = randomCash
script.Money:Play()
wait(3)
plr.PlayerGui.StoreRobbed.Enabled = false
else
plr.leaderstats.Cash.Value += 0
plr.leaderstats.Bounty.Value += 0
end
else
plr.leaderstats.Cash.Value += 0
plr.leaderstats.Bounty.Value += 0
end
end)
while true do
task.wait(300)
canrob = true
end