Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I get this Robbery system to take the money that's "stolen" and store it in my DataStorage?

Asked by 5 years ago

I've tried multiple methods but I just can't seem to get it to work, I'd really appreciate some support.

I absolutely do not want to use the standard ROBLOX leaderboard, but the moneySystem I've put together that makes use of ScreenGuis, sorry if this is a really simple fix but I'm quite new to scripting!

bankCashGiver

01local debounce = false
02local playerfound = false
03local player = game:GetService("Players")
04 
05--local moneyData = Instance.new("Folder",game.ReplicatedStorage)
06--moneyData.Name = "MoneyData" -- Once the game starts up, there will be a folder created in ReplicatedStorage.
07 
08local cash = game:GetService("DataStoreService"):GetDataStore("MoneyData")
09 
10--local dataStoreService = game:GetService("DataStoreService"):GetDataStore("MoneyDataStore")
11 
12game.Players.PlayerAdded:Connect(function(plr)
13    --local plrCash = game:GetService("DataStoreService"):GetDataStore("MoneyData")
14    --plrCash.Name = plr.Name -- Once the game starts up, a personal data folder will be created inside of "MoneyData."
15 
View all 73 lines...

DoorDetector (whenever you leave the building it would deposit the money into the account.)

01local replicatedStorage = game.ReplicatedStorage
02local MoneyData = game.ReplicatedStorage:FindFirstChild("MoneyData")
03 
04game.Players.PlayerAdded:Connect(function(plr)
05    local MoneyData = game.ReplicatedStorage:FindFirstChild("MoneyData")
06    local sourcePlayer = MoneyData:FindFirstChild(plr.Name)
07 
08end)
09 
10 
11script.Parent.Touched:Connect(function(hit)
12    if hit.Parent:FindFirstChild("HumanoidRootPart") then
13    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
14        if player.Robbing.Value == true then
15            game.ReplicatedStorage.HideRobberyGUI:FireClient(player)
View all 21 lines...

"Leaderboard"

01game.Players.PlayerAdded:Connect(function(player)
02 
03    local leaderstats = game.ReplicatedStorage:GetChildren("MoneyData")
04    leaderstats.Name = "MoneyData"
05 
06    local money = game.ReplicatedStorage.MoneyData:GetChildren("Cash")
07    money.Name = "Cash"
08 
09    local cc = Instance.new("IntValue", player)
10    cc.Name = "cashCollectedData"
11 
12    local robbing = Instance.new("BoolValue", player)
13    robbing.Name = "Robbing"
14    robbing.Value = false
15 
View all 21 lines...

Actual money GUI "LocalScript"

01local player = game.Players.LocalPlayer
02 
03wait() -- Allows the Client to load in before the Server interacts, avoiding any corruption/crashing.
04local moneyData = game.ReplicatedStorage:WaitForChild("MoneyData")
05local playerCash = moneyData:WaitForChild(player.Name)
06 
07script.Parent.cashDisplay.Text = "$ "..playerCash.Cash.Value
08playerCash.Cash.Changed:connect(function()
09    script.Parent.cashDisplay.Text = "$ "..playerCash.Cash.Value -- Updates the GUI whenever the Player earns a new amount of cash.
10end)

Any support would be heavily appreciated, been stumped for quite some time now! I should be able to provide any information if you need anything else.

0
Just to clarify, you have to money stolen and when the player leaves the game, you what it to save? XviperIink 428 — 5y
0
Yes, once you leave the building (transparent part in the doorway) you'll receive the money and it'll save whenever the Player leaves then rejoins. ofek163 7 — 5y
0
Where's the attempts and how did it not work? Also you shouldn't rely on random arbritary waits since they aren't reliable hiimgoodpack 2009 — 5y

Answer this question