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

I'm making an rpg and having problems with the leaderboard?

Asked by 5 years ago
Edited 5 years ago

I have mobs that when killed give xp and gold when killed. So far it's giving me errors about line 32 and line 73 with the onPlayerRespawned(player) function. I don't know what's wrong. Anyone have any suggestions?





function onXPChanged(player, XP, level) if XP.Value>=level.Value * 10 then XP.Value = XP.Value - level.Value * 30 level.Value = level.Value + 1 end end function onLevelUp(player, XP, level) if player.Character~=nil then for i = 1,5 do local fireworks = Instance.new("Part") fireworks.Shape = 0 fireworks.formFactor = "Symmetric" fireworks.Size = Vector3.new(1,1,1) fireworks.BrickColor = BrickColor.Random() fireworks.CFrame = player.Character.Head.CFrame + Vector3.new(0,2,0) fireworks.Parent = game.Workspace game:GetService("Debris"):AddItem(fireworks, 2) fireworks.Velocity = Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30)) end end local m = Instance.new("Hint") m.Parent = game.Workspace m.Text = player.Name .. " has leveled up!" wait(3) m.Parent = nil end function onPlayerRespawned(player) wait(5) player.Character.Humanoid.Health = player.leaderstats.Level * 999 player.Character.Humanoid.MaxHealth = player.leaderstats.Level * 1000 --[[ local stuff = player.Backpack:GetChildren() wait(5) for i = 1,#stuff do local name = stuff[i].Name if game.Starterpack:findFirstChild(name)==nil then stuff[i]:Clone().Parent = player.Backpack end end --]] end function onPlayerEntered(newPlayer) local stats = Instance.new("IntValue") stats.Name = "leaderstats" local xp = Instance.new("IntValue") xp.Name = "XP" xp.Value = 0 local level = Instance.new("IntValue") level.Name = "Level" level.Value = 1 local c = Instance.new("IntValue") c.Name = "Gold" c.Value = 0 xp.Parent = stats level.Parent = stats c.Parent = stats stats.Parent = newPlayer xp.Changed:connect(function() onXPChanged(newPlayer, xp, level) end) level.Changed:connect(function() onLevelUp(newPlayer, xp, level) end) newPlayer.Changed:connect(function (property) if (property == "Character") then onPlayerRespawned(newPlayer) end end) end game.Players.ChildAdded:connect(onPlayerEntered)
0
Post everything present in your Output window: We need precise errors or we can't help nearly as easily! Jahaziel_VanDerHas 238 — 5y

Answer this question