generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Level up problem

Previous Thread :: Next Thread 
MASTERKILL19121999 is not online. MASTERKILL19121999
Joined: 26 Jan 2013
Total Posts: 52
23 Jan 2014 08:26 AM
function onXPChanged(player, XP, level)
if XP.Value>=level.Value * 50 then
XP.Value = XP.Value - level.Value * 5
level.Value = level.Value + 1
dmg = dmg + 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 = "Ball"
fireworks.formFactor = "Symmetric"
fireworks.Transparency = 0.5
fireworks.Size = Vector3.new(2,2,2)
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 .. " Level has been updated, Congratulations!"
wait(5)
m.Parent = nil
end --Optional remove line 23 to 28 if a message when someone levels up is unwanted. To edit message change whats between the "s--

function onPlayerRespawned(player)
wait(5)
player.Character.Humanoid.MaxHealth = player.leaderstats.Lvl.Value * 50 + 50
player.Character.Humanoid.Health = player.leaderstats.Lvl.Value * 50 + 50
--[[
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 level = Instance.new("IntValue")
level.Name = "Lvl"
level.Value = 1

local xp = Instance.new("IntValue")
xp.Name = "XP"
xp.Value = 0

local gold = Instance.new("IntValue")
gold.Name = "Gold"
gold.Value = 0
level.Parent = stats
xp.Parent = stats
gold.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)




This is my RPG script, but i have a problem:
1. The health is only updating when reconnecting.
2. The damage +1 doesn't work.

Pls can someone help me?
Report Abuse
MASTERKILL19121999 is not online. MASTERKILL19121999
Joined: 26 Jan 2013
Total Posts: 52
23 Jan 2014 12:27 PM
Line 5 has to increase the number of damage, but it doesn't work.
Lines 32 and 33 have to increase health, but that doesn't work too.
Report Abuse
Avorable is not online. Avorable
Joined: 05 Jan 2014
Total Posts: 847
23 Jan 2014 12:31 PM
Could you post less code? Or at least number your lines?
Report Abuse
MASTERKILL19121999 is not online. MASTERKILL19121999
Joined: 26 Jan 2013
Total Posts: 52
23 Jan 2014 12:40 PM
1function onXPChanged(player, XP, level)
2if XP.Value>=level.Value * 50 then
3XP.Value = XP.Value - level.Value * 5
4level.Value = level.Value + 1
5dmg = dmg + 1
6end
7end

8function onLevelUp(player, XP, level)
9if player.Character~=nil then
10for i = 1,5 do
11local fireworks = Instance.new("Part")
12fireworks.Shape = "Ball"
13fireworks.formFactor = "Symmetric"
14fireworks.Transparency = 0.5
15fireworks.Size = Vector3.new(2,2,2)
16fireworks.BrickColor = BrickColor.Random()
17fireworks.CFrame = player.Character.Head.CFrame + Vector3.new(0,2,0)
18fireworks.Parent = game.Workspace
19game:GetService("Debris"):AddItem(fireworks, 2)
20fireworks.Velocity = 21Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30))
22end
23end
24local m = Instance.new("Hint")
25m.Parent = game.Workspace
26m.Text = player.Name .. " Level has been updated, Congratulations!"
27wait(5)
28m.Parent = nil
29end --Optional remove line 23 to 28 if a message when someone levels up is 30unwanted. To edit message change whats between the "s--

31function onPlayerRespawned(player)
32wait(5)
33player.Character.Humanoid.MaxHealth = player.leaderstats.Lvl.Value * 50 + 50
34player.Character.Humanoid.Health = player.leaderstats.Lvl.Value * 50 + 50
35--[[
36local stuff = player.Backpack:GetChildren()
37wait(5)
38for i = 1,#stuff do
39local name = stuff[i].Name
40if game.Starterpack:findFirstChild(name)==nil then
41stuff[i]:Clone().Parent = player.Backpack
42end
43end
44--]]
45end

46function onPlayerEntered(newPlayer)
47local stats = Instance.new("IntValue")
48stats.Name = "leaderstats"

49local level = Instance.new("IntValue")
50level.Name = "Lvl"
51level.Value = 1

52local xp = Instance.new("IntValue")
53xp.Name = "XP"
54xp.Value = 0

55local gold = Instance.new("IntValue")
56gold.Name = "Gold"
57gold.Value = 0
58level.Parent = stats
59xp.Parent = stats
60gold.Parent = stats

61stats.Parent = newPlayer

62xp.Changed:connect(function() onXPChanged(newPlayer, xp, level) end)
63level.Changed:connect(function() onLevelUp(newPlayer, xp, level) end)

64newPlayer.Changed:connect(function (property)
65if (property == "Character") then
66onPlayerRespawned(newPlayer)
67end
68end)
69end

70game.Players.ChildAdded:connect(onPlayerEntered)

Sorry, it's my first thread ever...
Report Abuse
Avorable is not online. Avorable
Joined: 05 Jan 2014
Total Posts: 847
23 Jan 2014 12:50 PM
The "dmg" only shows up on the fifth line. Are you sure it is correct like that?

What line does your Output say the code runs to? Or does it run without error?
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
23 Jan 2014 12:54 PM
I don't see you assign dmg anywhere, maybe you already did it. It's just that the script is too long, and I read your first function very fast and it didn't seem to have anything telling the script what dmg is.
Report Abuse
Avorable is not online. Avorable
Joined: 05 Jan 2014
Total Posts: 847
23 Jan 2014 12:58 PM
>>Kingmouli
I used Ctrl+F.
That was the only place "dmg" was used.

So there's that..
Report Abuse
MASTERKILL19121999 is not online. MASTERKILL19121999
Joined: 26 Jan 2013
Total Posts: 52
23 Jan 2014 01:00 PM
And the health?
Report Abuse
VilleSlay is not online. VilleSlay
Joined: 14 May 2011
Total Posts: 1405
23 Jan 2014 01:02 PM
The inefficiency is strong with this script.

~~> Ville <~~
Report Abuse
Avorable is not online. Avorable
Joined: 05 Jan 2014
Total Posts: 847
23 Jan 2014 01:10 PM
>> MASTERKILL19121999
You should check if the Character exists before messing with it just in case.
Are you sure it isn't working?

This code is bad for looping, but it's what I use:
repeat wait() until player.Character
Report Abuse
MASTERKILL19121999 is not online. MASTERKILL19121999
Joined: 26 Jan 2013
Total Posts: 52
23 Jan 2014 01:15 PM
The real problem is that it only updates if you enter the game.
Report Abuse
MASTERKILL19121999 is not online. MASTERKILL19121999
Joined: 26 Jan 2013
Total Posts: 52
23 Jan 2014 01:18 PM
And i'm not a really good scripter.

I mean; i'm just 14...
Report Abuse
Avorable is not online. Avorable
Joined: 05 Jan 2014
Total Posts: 847
23 Jan 2014 01:19 PM
Go to line 65 and change it to:
if (property == "Character") and player.Character then

This way it will only work when the character is added instead of when it is added or removed.
Report Abuse
MASTERKILL19121999 is not online. MASTERKILL19121999
Joined: 26 Jan 2013
Total Posts: 52
23 Jan 2014 01:20 PM
Thank you very much!
Report Abuse
VilleSlay is not online. VilleSlay
Joined: 14 May 2011
Total Posts: 1405
23 Jan 2014 01:29 PM
"I mean, I'm only 14."
I started coding 3 years ago. I am 14..

~~> Ville <~~
Report Abuse
Avorable is not online. Avorable
Joined: 05 Jan 2014
Total Posts: 847
23 Jan 2014 01:32 PM
>>VilleSlay
19, started coding 7 years ago. Still don't know all that much lol.
Report Abuse
VilleSlay is not online. VilleSlay
Joined: 14 May 2011
Total Posts: 1405
23 Jan 2014 01:34 PM
This thing motivates me to keep on doing it: https://www.youtube.com/watch?v=dmM_xDzy2nU

~~> Ville <~~
Report Abuse
MASTERKILL19121999 is not online. MASTERKILL19121999
Joined: 26 Jan 2013
Total Posts: 52
23 Jan 2014 02:20 PM
That's from scratch, i can work with that, but this is more difficult.
And i started coding by myself on roblox 3 months ago, so not for a long time...

And it's still not working :(
Report Abuse
EcIiptic is not online. EcIiptic
Joined: 12 Aug 2009
Total Posts: 13737
23 Jan 2014 02:26 PM
I'm 15 and I can easily do what your trying to do.

But I don't waste my team reading like 100 lines of code.
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
23 Jan 2014 02:27 PM
Free model
Report Abuse
Avorable is not online. Avorable
Joined: 05 Jan 2014
Total Posts: 847
23 Jan 2014 02:28 PM
>>EcIiptic
Did you really read all that?
Report Abuse
EcIiptic is not online. EcIiptic
Joined: 12 Aug 2009
Total Posts: 13737
23 Jan 2014 02:29 PM
*Time


And no, why would I?


lol
Report Abuse
Avorable is not online. Avorable
Joined: 05 Jan 2014
Total Posts: 847
23 Jan 2014 02:42 PM
>>EcIiptic
The way you said that, it sounded like you read all that lol
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image