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

Even though a player is the same level as in the if statement, the else statement runs instead,help?

Asked by 5 years ago

I am making an if statement, but else runs even though someone is 2nd level or higher.

Item = script.Parent:FindFirstChildOfClass("Tool"):Clone()

val = 2



script.Parent.Touched:Connect(function(hit)

local plr = game.Players:GetPlayerFromCharacter(hit.Parent)

local char = hit.Parent

local hum = hit.Parent:FindFirstChild("Humanoid")

if hum then

if plr:WaitForChild("leaderstats").Lvl.Value >= val then-- this doesn't run, but it should

local tool = char:FindFirstChildOfClass("Tool")

if tool then

tool:Remove()

Item.Name = "Sword"

Item.Parent = plr.Backpack

else

Item.Parent = plr.Backpack

end

else--This runs, when it shouldn't

plr.PlayerGui.ScreenGui.TextLabel.Visible = true

plr.PlayerGui.ScreenGui.TextLabel.TextColor3 = Color3.new(170,0,0)

plr.PlayerGui.ScreenGui.TextLabel.Text = "ERROR!"

wait(1)

plr.PlayerGui.ScreenGui.TextLabel.TextColor3 = Color3.new(0,0,0)

plr.PlayerGui.ScreenGui.TextLabel.Text = "You don't have enough XP!"

wait(2)

plr.PlayerGui.ScreenGui.TextLabel.Visible = false

end

end

end)
0
Did you make sure that the players Lvl is greater then or equal to 2? DollorLua 235 — 5y
0
Yes MaciBoss1950 16 — 5y
0
maybe put val = 2 inside of the touched function? AnonymousDeveloper13 22 — 5y
0
Doesn't work MaciBoss1950 16 — 5y
0
When I print the Lvl value it says 0, even though it says on the leaderboard it is 5 MaciBoss1950 16 — 5y

1 answer

Log in to vote
0
Answered by
bjr29 40
5 years ago

Try using

'>'

Instead of

'>='

0
Doesn't work MaciBoss1950 16 — 5y
Ad

Answer this question