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

How To Get Exp When A Humanoid Dies?

Asked by 3 years ago

I've had 2 of this same questions in different forums and no one can figure why it doesn't work. I have a basic roblox dummy in the workspace and it has a humanoid and everything. So When I Kill the Dummy the GiveExp Script says {xp is not a valid member of Folder}, here is the scripts.

----Leaderstats Script(Normal Script)----

game.Players.PlayerAdded:Connect(function(plr)
    local leaderstats = Instance.new("Folder")
    leaderstats.Parent = plr
    leaderstats.Name = "Leaderstats"

        local lvl = Instance.new("IntValue")
        lvl.Parent = leaderstats
        lvl.Name = "Level"

        local xp = Instance.new("IntValue")
        xp.Parent = leaderstats
        xp.Name = "Exp"

   end)

----GiveExp Script (Normal Script)----

local leaderstats = game.Players.LocalPlayer:WaitForChild("Leaderstats")

game.Workspace.Dummy.Humanoid.Died:Connect(function()
            leaderstats.Exp.Value = leaderstats.xp.Value + 10000
       end)

I've have asked this so many times and no brilliant mind can figure this out, could somebody take the time to help this old lad?

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

There's no such thing as LocalPlayer in Server Scripts. You're also doing xp.Value instead of Exp.Value

0
Could you show the code that I should change/fix? CodedStars 70 — 3y
0
For your script to work, you'd have to create another script which detects which player killed it and such, which I don't have time for right now, sorry. zboi082007 270 — 3y
0
*and after you have the payer, copy your give xp script but fix the things I pointed out. zboi082007 270 — 3y
Ad

Answer this question