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

Scripts wont run within the player object?

Asked by 5 years ago

So I'm not sure if I'm missing anything here. Im trying to make a skill system that will automatically change levels based on the xp the player has and of course calculate how much xp will be needed to obtain the next level after a level up occurs.

!How it looks in starter player

I have been trying to test this with a gui button that adds 20 xp each time I click it and that works fine. However none of the scripts inside the value object work. I doubt theyre even acknowledged because the first line doesnt display anything in the console.

Here is the GetNextLevelXP code:

print(script.Name .. " exists")

local nextLevel = 0
local points, output = 0
local maxLevel = script.Parent.Level.Value

print("Running")

for i = 1, maxLevel + 1 do
    points = points + math.floor(i + 300 * math.pow(2,i/7))
    output = math.floor(points / 5)
    nextLevel = output
end
print(nextLevel)

script.Disabled = true

and the LevelUp code:

print(script.Name .. " exists") 

skill = script.Parent 
currentXP = skill.Value nextLevelXP = skill.NextLevelXP.Value 

print("Running") 

skill.Changed:Connect(function() 
    if (currentXP >= nextLevelXP) then 
        print("LEVEL UP! YOU ARE NOW LEVEL " .. skill.Level .. " IN " .. skill.Name) 
        skill.GetNextLevelXP.Disabled = false 
    end 
    skill.Difference.Value = nextLevelXP - currentXP print("xp gained") 
end)

PS. To the scriptinghelper or stackedit devs, fix your code markdown! I cant even copy and paste code from the studio without having to edit the whole thing!

0
Why do they appear to be disabled? DeceptiveCaster 3761 — 5y
0
Mainly with GetNextLevelXP, Just set them up so that it gets the values needed when a new player loads and whenever they level up in that skill Zukaazora 30 — 5y

Answer this question