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

Why am I getting an error? It seems to me that the solution is very simple, but I cannot find it.

Asked by 2 years ago

Why am I getting an error?

A mistake in this moment - "plr.stat.curent.Value=plr.stat.curent.Value+1"

Script:

local Reward = require(game.ServerStorage:WaitForChild("Reward"))
local RewardData = Reward[1]
local stat=RewardData["stats"]
local curent=RewardData["curent"]
local reward=RewardData["reward"]

game.Players.PlayerAdded:Connect(function(plr)
    plr.stat.curent.Value=plr.stat.curent.Value+1

end)

ModuleScript:

local day = {
    [1]={
        stats='PlayerStats',
        curent='DoubleXP',
        reward = 100000
        }
}
return day
0
This isn't a solution, but a better way to add or subtract from a value is "plr.stat.curent.Value += 1". Use a - for subtraction. itchymoonfire 179 — 2y
0
This is the error it gives me - "stat is not a valid member of Player "Players.ZaharKor12"" ZaharKor12 12 — 2y
0
Did you check stat is a valid member then? AProgrammR 398 — 2y

1 answer

Log in to vote
0
Answered by
sngnn 274 Moderation Voter
2 years ago
Edited 2 years ago

plr.stat doesn't exist. Instead, use the variable you set:

game.Players.PlayerAdded:Connect(function()
    curent.Value=curent.Value+1
end)

Also, instead, you should use curent.Value += 1. It's another way to add to a value.

0
I didn't quite understand what you did ZaharKor12 12 — 2y
Ad

Answer this question