I'm trying to make a bigger duffel bag gamepass. Here is what my script for money giving looks like :
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.ShowRobberyGUI:FireClient(Players[i]) end Players[i].Robbing.Value = true if Players[i].CashCollected.Value < 1000 then Players[i].CashCollected.Value = Players[i].CashCollected.Value + 10 end end return Players end while wait(0.2) do GetPlayersInPart(game.Workspace.Detector) end
I'm trying to make it so if the player has the Bigger Duffel Bag gamepass [https://www.roblox.com/library/1607774359/Bigger-Duffel-Bag-PRE-ORDER] he will get 3.5k money instead of 1k. Would appreciate some help.
You'd use PlayerHasPass from the gamepass service. https://wiki.roblox.com/index.php?title=API:Class/GamePassService/PlayerHasPass
It would look something like this.
Players[i].Robbing.Value = true if game:GetService("GamePassService"):PlayerHasPass(Players[i], gamepassid) then -- Replace "gamepassid" with whatever gamepass you're using. In your case it would be 1607774359. if Players[i].CashCollected.Value < 3500 then Players[i].CashCollected.Value = Players[i].CashCollected.Value + 10 else if Players[i].CashCollected.Value < 1000 then Players[i].CashCollected.Value = Players[i].CashCollected.Value + 10 end end end
I haven't tested this however and it may not work. I'm not too sure but you can sort of get an idea of how it should work.
Also I would strongly suggest storing important values like Money and such, serverside using remote events and functions with filtering enabled so that you can avoid exploiters. https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events
Edit:
Try this?
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.ShowRobberyGUI:FireClient(Players[i]) end Players[i].Robbing.Value = true if not game:GetService("GamePassService"):PlayerHasPass(Players[i], 1607774359) then if Players[i].CashCollected.Value < 1000 then Players[i].CashCollected.Value = Players[i].CashCollected.Value + 10 end else if Players[i].CashCollected.Value < 3500 then Players[i].CashCollected.Value = Players[i].CashCollected.Value + 10 end end end return Players end while wait(0.2) do GetPlayersInPart(game.Workspace.Detector) end