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

How do you check the leaderstats to see if the player is a certain "Tier" (or level)?

I'm trying to make a game with an equipment GUI, and I encountered an error.

My script is below.

script.Parent.MouseButton1Click:Connect(function()
	if game.Players.LocalPlayer.leaderstats.Tier.Value >= 5 then
	game.Players.LocalPlayer.EquippedTool.Value = tostring(script.Parent.Name)
	script.Parent.BorderSizePixel = 5
	script.Parent.ZIndex = 2
	for i, image in pairs(script.Parent.Parent:GetChildren()) do
		if image.Name ~= script.Parent.Name then
		image.ZIndex = 1
		image.BorderColor3 = Color3.new(0,0,0)
		image.BorderSizePixel = 1
		end
	end
	script.Parent.BorderColor3 = Color3.new(255,0,0)
	script.Parent.Parent.Parent.TextButton.Text = "Currently Equipped: "..script.Parent.Name
		else
		script.Parent.Parent.Parent.TextButton.Text = "You need to be at least Tier 5 for this!"
	end
end)

It comes out with an error that says "Tier is not a valid member of IntValue"

I have no idea how to fix this.

Thank you!

2 comments

0

Your hierarchy is wrong.

1

Also, what you’re doing is the worst thing to do. Seeing your code, it’s a LocalScript. You’re checking the requirements on the client, which only gives the client power.

1 answer

✓ Accepted answer
--[[ This i can help you with. Try this example. 
if plr.leaderstats:WaitForChild("Tier").Value == 100 then
 (function here)
end 
if this doesn't work. It either means Tier doesn't exist in the hierarchy. Add a function to wait for the object. If my example worked. Then it's been fixed. You're welcome. ]]

17 comments

0

WaitForChild can error if it waits too long.

0

One of my scripts once broke, froze my studio for waiting too long.

0

Ah, i see. Thanks for the headers.

0

how would I put a plr function inside of the script in order for that to work?

0

sorry, I'm not super good at scripting...

0

What do you mean Plr function?

0

Like the function to wait for the object

0

o i see. if plr.leaderstats:WaitForChild("Tier").Value == 100 then

0

plr show up as wrong though

0

that's an example though.

0

if game.Players.LocalPlayer.leaderstatsWaitForChild("Tier").Value >= 5 then | do this.

0

Wait one sec... I have to do something I’ll try it really soon! Thanks

0

Could you accept my answer? And, no problem.

0

I’ll accept it!

0

Thanks!

0

Thank you! If there is a problem I’ll let you know

0

Alright. You're welcome :)

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