Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

3 comments

0

try on line 2: local cash = game.Players.LocalPlayers.leaderstats.Cash

0

then on line 3 try: cash.Value = cash.Value -40

0

if that doesn't work, comment and i'll find a solution

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.