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

My textLabel script that shows the Level is not working, help?

Asked by 5 years ago
Edited 5 years ago

The script is about a textLabel that shows the level of the local player without it ("it" is the Level) being an IntValue on the Leaderboard.

local textLabel = script.Parent
local Level = ("Level").Name
local XP = ("XP").Name
local Humanoid = script.Parent.Parent.Parent.Parent.Parent.Human

Level.Value = 0
XP.Value = 0

function KillForXP()
XP.Value = XP.Value + 100
wait(0.1)
script:remove()
end
Humanoid.Died:connect(KillForXP)

function XPforLevel
Level.Value = Level.Value + 1 -- here the first Level is red underlined :(, help?
if Level.Value + 1 then 
    XP.Value = 0
end
wait(0.1)
script:remove
end
XP.Value = 1000:connect(XPforLevel)

textLabel.Text = Level.Value -- the textLabel ( Parent )
0
I think it is very clear... SwingingMelons -18 — 5y
0
This has a lot of basic syntax errors. Take a look at http://wiki.roblox.com/index.php?title=Intro_to_Scripting Optikk 499 — 5y
0
local Level = ("Level").Name This is your problem. TheNextEvolution 0 — 5y
0
what should it be? SwingingMelons -18 — 5y
View all comments (9 more)
0
I did the same thing to the local XP = ("XP").Name and there is no error SwingingMelons -18 — 5y
0
Level needs to = where ever the players level is this is from one of my scripts to give you an idea. local Playa = game.Players.LocalPlayer local stuff = Playa:WaitForChild("Stuff") local level = stuff:WaitForChild("Level") TheNextEvolution 0 — 5y
0
no sense at all... SwingingMelons -18 — 5y
0
Okay well I gave you the answer you might need to go to wiki.roblox.com and go learn the basics of scripting before trying to do something when you don't understand the basics of scripting. TheNextEvolution 0 — 5y
0
Playa? Stuff? I don't know the basic of scripting after all? SwingingMelons -18 — 5y
0
Where is the players level value located? TheNextEvolution 0 — 5y
0
The issues that I notice is lines 2-3: You're trying to get a name from string values. ("Level".Name) To fix this, just define the objects. (For example, if a wanted to get my kill stats, `local Kills = LocalPlayer.leaderstats.Kills`) TheeDeathCaster 2368 — 5y
0
The thing is that I don't want to add leaderstats SwingingMelons -18 — 5y
0
You can get rid of the red underline in line 17 by simply adding (), function XPforLevel() and the underline will be gone. HeyItzDanniee 252 — 5y

2 answers

Log in to vote
1
Answered by
Optikk 499 Donator Moderation Voter
5 years ago

Most of the problems are from syntax errors. For example, you forgot to add parentheses to the function at line 16. Read the errors that the "red lines" say and most of this should be fixed.

0
I corrected every syntax mistake. But I need help on line 24, plz help? SwingingMelons -18 — 5y
Ad
Log in to vote
1
Answered by 5 years ago

There are lots of syntax errors, stated by previous answers and comments. There is also a lot of deprecated code in your script. Big no no. Let me fix it up. Assuming your XP and Level values are in a leaderstats:

local plr = game:GetService('Players').LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char.Humanoid -- idk why you even put 50 script.Parent 
local label = script.Parent
local leaderstats = plr:WaitForChild"leaderstats"


local xp = leaderstats:WaitForChild"XP"
local lvl = leaderstats:WaitForChild"Level"

function killForXP()
    xp.Value = xp.Value + 100
    wait(.1)
    script:Destroy() -- :Destroy() not :remove()
end

humanoid.Died:Connect(killForXP) -- :Connect not :connect

function xpForLevel() -- forgot the brackets
    lvl.Value = lvl.Value + 1
    xp.Value = 0

    wait(.1)
    script:Destroy()
end

xp.Changed:Connect(xpForLevel)

lvl.Changed:Connect(function() 
    label.Text = "Level: "..lvl.Value
end)
0
This would work but I don't want to add anything to the leaderboard as I said at the description SwingingMelons -18 — 5y

Answer this question