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

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

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

3 comments

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.

0

This is the error it gives me - "stat is not a valid member of Player "Players.ZaharKor12""

0

Did you check stat is a valid member then?

1 answer

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.

1 comment

0

I didn't quite understand what you did

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