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

How would i reference a leaderstat?

The script im trying to run is:

local Player = game.Players.LocalPlayer
local Leaderstat = Player:WaitForChild("leaderStats")
local stat = Leaderstat["strength"]

if Leaderstat.strength.value = 100 then
	Player.leaderstats.Level.value = Player.leaderstats.Level.value +1
end

What i'm trying to do is when the payers strength reaches an amount, 100 in this case, I want their level to go up. When i run the game and use a tool,i made it so it instantley gets me to 100 for now, to get to 100 the level doesn't change.

1 answer

This is very incorrect. I can polish it up for you. There is too much that I can explain here so I will only type my stuff.

game.Players.PlayerAdded:Connect(function(player)
	local ls = Instance.new("Model",player)
	ls.Name = "leaderstats"
	local stat1 = Instance.new("IntValue",ls)
	stats.Name = "Strength"
	local stat2 = Instance.new("IntValue",ls)
	stat2.Name = "Level"
	stat2.Value = 1
	local buildup = 1
	if stat1.Value = 100 * buildup then
		stat2.Value = stat2.Value + 1
		--Customize buildup gain which ever way you want or just use this system.
		buildup = buildup + 1
	end
end)

2 comments

0

on line 10 its has error line under the = and the then

0

it's just a syntax error, make it == and it should work

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