You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I would like the cash to spawn on the character after death. -
What is the issue? Include screenshots / videos if possible!
The issue is that I also want the character to have a starter character, but when I add that the cash does not drop. It works if I don’t have a starter character. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have currently tried changing things inside the starter character to no success, I’ve also browsed the internet and Creator Hub for answers to this
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
The code in ServerScripts to spawn a clone of cash in ReplicatedStorage is:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Money = ReplicatedStorage:WaitForChild("Money")
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("CashData")
game.Players.PlayerAdded:Connect(function(Player)
local Leaderstats = Instance.new("Folder")
Leaderstats.Name = "leaderstats"
Leaderstats.Parent = Player
local Minutes = Instance.new("IntValue")
Minutes.Name = "Cash"
Minutes.Value = 0
Minutes.Parent = Leaderstats
local Data = DataStore:GetAsync(Player.UserId)
if Data then
Minutes.Value = Data
end
local Gui = Player.PlayerGui:WaitForChild("MoneyGui")
Gui.CashFrame.Cash.Text = Player.leaderstats.Cash.Value .. " (g)"
Player.leaderstats.Cash.Changed:Connect(function()
local Gui = Player.PlayerGui:WaitForChild("MoneyGui")
Gui.CashFrame.Cash.Text = Player.leaderstats.Cash.Value .. " (g)"
end)
Player.CharacterAppearanceLoaded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
if hum then
hum.Died:Connect(function()
if Player.leaderstats.Cash.Value > 0 then
local MoneyClone = Money:Clone()
MoneyClone.ProximityPrompt.ObjectText = Player.Name .. "'s " .. "Cash"
MoneyClone.ProximityPrompt.ActionText = "Pick Up " .. Player.leaderstats.Cash.Value * 3 / 4 .. "$"
MoneyClone.CashAmmount.Value = Player.leaderstats.Cash.Value * 3 / 4
MoneyClone.CFrame = char:WaitForChild("HumanoidRootPart").CFrame
MoneyClone.Parent = workspace
Player.leaderstats.Cash.Value -= Player.leaderstats.Cash.Value * 3 / 4
--disabled start (impossible to get negative money)
elseif Player.leaderstats.Cash.Value >= -1 and Player.leaderstats.Cash.Value < 0 then
local MoneyClone = Money:Clone()
MoneyClone.ProximityPrompt.ObjectText = Player.Name .. "'s " .. "Cash"
MoneyClone.ProximityPrompt.ActionText = "Pick Up " .. 500 .. "$"
MoneyClone.CashAmmount.Value = 500
MoneyClone.CFrame = char:WaitForChild("HumanoidRootPart").CFrame
MoneyClone.Parent = workspace
Player.leaderstats.Cash.Value -= 500
--disabled end
end
end)
end
end)
while wait(1) do
Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + 1
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
DataStore:SetAsync(Player.UserId, Player.leaderstats.Cash.Value)
end)