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

I am having an error with my leaderstats is my script wrong or right, and is there any problems?

Asked by 4 years ago

My leaderstats script keeps having the same problem ServerScriptService:20 plr(a nil value) i have changed it around to do LocalPlayer but its the same error here is the script: ```lua

local ds = game:GetService("DataStoreService"):GetDataStore("DataStore1") local plr = game.Players.LocalPlayer game.Players.PlayerAdded:Connect(function(PlayerEntered) if PlayerEntered then if PlayerEntered and not plr then game.Players:GetPlayerFromCharacter(plr)

        local leaderstats = Instance.new("Folder")
        leaderstats.Name = "leaderstats"
        leaderstats.Parent = plr

        local TeaDrank = Instance.new("NumberValue")
        TeaDrank.Name = "Tea Drank"
        TeaDrank.Parent = leaderstats
        TeaDrank.Value = 0

        local cash = Instance.new("IntValue")
        cash.Name = "Cash"
        cash.Parent = leaderstats
        cash.Value = 50 + game.Players.LocalPlayer.leaderstats.Cash.Value / 0

    end
end

end) ``` Do you think it is wrong or right? P.S this is for a youtube tutorial so I have to post the vid in 1 day. So pls help.

0
I'm pretty sure only server-script based scripts work in the ServerScriptService, this may be your issue. milkydadup 1 — 4y
0
You have to specifically tell the script which player, LocalPlayer is only used for Client side. UltraUnitMode 419 — 4y

Answer this question