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

How to edit player propirity?

Asked by
ANE_bot 17
5 years ago

Hai! I'm working on a game behind bars and I was working on the bank, I have a cash system in place, but don't know how to make the value go up or down!

--Da code:
game.Players.PlayerAdded:connect(function(p)
local stats = Instance.new("IntValue", p)
stats.Name = "leaderstats"
local money = Instance.new("IntValue", stats)
money.Name = "Cash"
money.Value = 100

I was thinking something like:

function hit(hit)
    game.players.player.propirity.cash = cash + 1000 -- propirity is a real intvalue, I checked.

O.O so. um. I think thats it?

thanks, archmantella13(AKA ANE_bot)

0
It will not find the player because no value is set and you got to do player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1000 aandmprogameing 52 — 5y

1 answer

Log in to vote
1
Answered by
Prestory 1395 Moderation Voter
5 years ago
Edited 5 years ago

Try this

game.Players.PlayerAdded:connect(function(p)

wait()

if p:FindFirstChild('leaderstats') then return else

local LeaderstatsFolder = Instance.new("Folder", p)

LeaderstatsFolder.Name = "leaderstats"

local Money = Instance.new("IntValue", LeaderstatsFolder)

Money.Name = "Cash"

Money.Value = 100
end
end)

and put this script inside the part

Debounce = false

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and not Debounce then
Debounce = true
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player:WaitForChild('leaderstats').Cash.Value = player.leaderstats.Cash.Value + 1000
wait(2)
Debounce = false
end
end)

0
also add a wait aandmprogameing 52 — 5y
0
Debounce is there Prestory 1395 — 5y
0
Thank you! ANE_bot 17 — 5y
Ad

Answer this question