I have 2 scripts which handle this:
The Cash Touched Function(This is in the cash instance that i touch):
local db = false
script.Parent.Touched:Connect(function(child)
local hum = child.Parent:FindFirstChild("Humanoid")
if hum then
local foundPlayer = game.Players:FindFirstChild(hum.Parent.Name)
if foundPlayer then
if db == false then
db = true
foundPlayer.SavedValues.DogeBucks.Value += math.random(script.Parent.Low.Value, script.Parent.High.Value)
game.ReplicatedStorage.CollectedCash:FireClient(foundPlayer)
script.Parent:Destroy()
end
end
end
end)
Handles the DogeBucks and rewrites value on bottom left textlabel:
local DogeBucksLabel = GameUI.AmountBucks
DogeBucksLabel.Text = "$"..tostring(player.SavedValues.DogeBucks.Value)
game.ReplicatedStorage.CollectedCash.OnClientEvent:Connect(function()
script.CashCollect:Play()
end)
player.SavedValues.DogeBucks:GetPropertyChangedSignal("Value"):Connect(function()
DogeBucksLabel.Text = "$"..tostring(player.SavedValues.DogeBucks.Value)
end)
Video of the Problem(Please look everything through):
All Help is highly appreciated