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

My Exp/leveling scripts are not working... Could someone look over them please? [closed]

Asked by 5 years ago

Leaderstats (ServerScriptService)

game.Players.PlayerAdded:Connect(function(Player) 
    local Leaderstats = Instance.new("Folder", Player) 
    Leaderstats.Name = "Leaderstats" 
    local Level = Instance.new("IntValue", Leaderstats) 
    Level.Name = "LevelLable" 
    Level.Value = 0 
    local Exp = Instance.new("IntValue", Leaderstats) 
    Exp.Name = "ExpLable" 
    Exp.Value = 0 
    if Player.Character and Player.Character:WaitForChild("Humanoid") then
        Player.Character.Humanoid.MaxHealth = 100 + Level.Value*10
    end
    Level.Changed:Connect(function(value)
    if Player.Character and Player.Character:FindFirstChild("Humanoid") then
        Player.Character.Humanoid.MaxHealth = 100 + Level.Value*10
        end
    end)
    Player.CharacterAdded:Connect(function(character)
        character:WaitForChild("Humanoid").MaxHealth = 100 + Level.Value*10
        Player.Character.Humanoid.Health = Player.Character.Humanoid.MaxHealth
    end)
end)

Character script

local exp = script.Parent.Config.XP.Value

local Humanoid = script.Parent.Humanoid
function PwntX_X() 
local tag = Humanoid:findFirstChild("creator") 
    if tag ~= nil then 
        if tag.Value ~= nil then 
local Leaderstats = tag.Value:FindFirstChild("Leaderstats") 
            if Leaderstats ~= nil then 
Leaderstats.XP.Value = Leaderstats.XP.Value + exp
wait(0.1) 
script:remove()
            end 
        end 
    end 
end 
Humanoid.Died:connect(PwntX_X) 

If you need anything else let me know... Thanks in advance...

0
Not to be harsh, but the probability of someone answering you is low. Give us more information. How is it not working? What are the exact errors? Line numbers? What do you think is the problem? ScrewDeath 153 — 5y
0
What does the error in the output say? AltNature 169 — 5y
0
:remove() is deprecated and I believe it can cause issues. Use :Destroy(). xPolarium 1388 — 5y

Closed as Non-Descriptive by User#19524

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
Audiimo 105
5 years ago

This should be very simple. In the tool the player uses to kills the NPC you need to check if the NPC is an NPC and that it is dead and then you need to give the EXP accordingly. I'm not 100% if you can check if the NPC died by a player but you could try seeing if the parent of the tool (assuming the tool killed it) is a character and then use :GetPlayerFromCharacter() to access the player (assuming the exp is stored in the player somewhere).

Ad