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

How to fix my bill script, leaderstats is not a member of me?

Asked by 2 years ago

I have leaderstats in local player and I have made sure that my cash value is named the exact name I have tried many things but it still says that leader stats is not a member of blueturtle8908 (me). I checked that the value is still there and it is so I don't know. It is a local script if that makes a difference
Any ways, here is my code.

while true do
    local cash = game.Players.LocalPlayer.leaderstats
    cash.Cash.Value = Cash.Value - 40
    script.Parent.Bill.Visible = true
    wait(5)
    script.Parent.Bill.Visible = false
    wait(60)
end
0
try on line 2: local cash = game.Players.LocalPlayers.leaderstats.Cash JesseSong 3916 — 2y
0
then on line 3 try: cash.Value = cash.Value -40 JesseSong 3916 — 2y
0
if that doesn't work, comment and i'll find a solution JesseSong 3916 — 2y

1 answer

Log in to vote
1
Answered by 2 years ago

It doesn't work since your trying to edit a server object with a local script. What you should do is inside a server script inside of ServerScriptService do this

local interval = 10 -- Change to how often you want to show the bill

while true do
    for i,v in pairs(game.Players:GetChildren()) do
        local cash = v.leaderstats.Cash
        cash.Value = cash.Value - 40
        game.ReplicatedStorage.ShowBill:FireClient(v)
    end
    wait(interval)
end

Then you want to insert a RemoteEvent inside of ReplicatedStorage and name it "ShowBill" Once you do that with a local script inside of the ScreenGui with your bill insert this script

local dissapearTime = 5 -- How long you want the bill to show for

game.ReplicatedStorage.ShowBill.OnClientEvent:Connect(function()
    script.Parent.Enabled = true
    wait(dissapearTime)
    script.Parent.Enabled = false
end)

And that should be it.

Ad

Answer this question