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

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

Asked by
cryrc 8
5 years ago

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!

0
Your hierarchy is wrong. User#19524 175 — 5y
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. User#19524 175 — 5y

1 answer

Log in to vote
0
Answered by
Delude_d 112
5 years ago
Edited 5 years ago
--[[ 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. ]]
0
WaitForChild can error if it waits too long. User#19524 175 — 5y
0
One of my scripts once broke, froze my studio for waiting too long. User#19524 175 — 5y
0
Ah, i see. Thanks for the headers. Delude_d 112 — 5y
0
how would I put a plr function inside of the script in order for that to work? cryrc 8 — 5y
View all comments (13 more)
0
sorry, I'm not super good at scripting... cryrc 8 — 5y
0
What do you mean Plr function? Delude_d 112 — 5y
0
Like the function to wait for the object cryrc 8 — 5y
0
o i see. if plr.leaderstats:WaitForChild("Tier").Value == 100 then Delude_d 112 — 5y
0
plr show up as wrong though cryrc 8 — 5y
0
that's an example though. Delude_d 112 — 5y
0
if game.Players.LocalPlayer.leaderstatsWaitForChild("Tier").Value >= 5 then | do this. Delude_d 112 — 5y
0
Wait one sec... I have to do something I’ll try it really soon! Thanks cryrc 8 — 5y
0
Could you accept my answer? And, no problem. Delude_d 112 — 5y
0
I’ll accept it! cryrc 8 — 5y
0
Thanks! Delude_d 112 — 5y
0
Thank you! If there is a problem I’ll let you know cryrc 8 — 5y
0
Alright. You're welcome :) Delude_d 112 — 5y
Ad

Answer this question