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 4 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)----

01game.Players.PlayerAdded:Connect(function(plr)
02    local leaderstats = Instance.new("Folder")
03    leaderstats.Parent = plr
04    leaderstats.Name = "Leaderstats"
05 
06        local lvl = Instance.new("IntValue")
07        lvl.Parent = leaderstats
08        lvl.Name = "Level"
09 
10        local xp = Instance.new("IntValue")
11        xp.Parent = leaderstats
12        xp.Name = "Exp"
13 
14   end)

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

1local leaderstats = game.Players.LocalPlayer:WaitForChild("Leaderstats")
2 
3game.Workspace.Dummy.Humanoid.Died:Connect(function()
4            leaderstats.Exp.Value = leaderstats.xp.Value + 10000
5       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 4 years ago
Edited 4 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 — 4y
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 — 4y
0
*and after you have the payer, copy your give xp script but fix the things I pointed out. zboi082007 270 — 4y
Ad

Answer this question