Okay, I have two questions. Here is the first. So, this one is pretty simple, how would I loop this function forever?
function LevelUp() if Player.Exp.Value >= 100 then Player.PlayerLevel.Value = 2 elseif Player.Exp.Value >= 300 then Player.PlayerLeve.Valuel = 3 elseif Player.Exp.Value >= 600 then Player.PlayerLeve.Valuel = 4 elseif Player.Exp.Value >= 1000 then Player.PlayerLevel.Value = 5 elseif Player.Exp.Value >= 1500 then Player.PlayerLevel.Value = 6 elseif Player.Exp.Value >= 2000 then Player.PlayerLevel.Value = 7 elseif Player.Exp.Value >= 2500 then Player.PlayerLevel.Value = 8 elseif Player.Exp.Value >= 3000 then Player.PlayerLevel.Value = 9 elseif Player.Exp.Value >= 4000 then Player.PlayerLevel.Value = 10 elseif Player.Exp.Value >= 5000 then Player.PlayerLevel.Value = 11 elseif Player.Exp.Value >= 6500 then Player.PlayerLevel.Value = 12 elseif Player.Exp.Value >= 8000 then Player.PlayerLevel.Value = 13 elseif Player.Exp.Value >= 9500 then Player.PlayerLevel.Value = 14 elseif Player.Exp.Value >= 11000 then Player.PlayerLevel.Value = 15 elseif Player.Exp.Value >= 12500 then Player.PlayerLevel.Value = 16 elseif Player.Exp.Value >= 14000 then Player.PlayerLevel.Value = 17 elseif Player.Exp.Value >= 15500 then Player.PlayerLevel.Value = 18 elseif Player.Exp.Value >= 18000 then Player.PlayerLevel.Value = 19 elseif Player.Exp.Value >= 21000 then Player.PlayerLevel.Value = 20 elseif Player.Exp.Value >= 25000 then Player.PlayerLevel.Value = 21 elseif Player.Exp.Value >= 30000 then Player.PlayerLevel.Value = 22 elseif Player.Exp.Value >= 35000 then Player.PlayerLevel.Value = 23 elseif Player.Exp.Value >= 40000 then Player.PlayerLevel.Value = 24 elseif Player.Exp.Value >= 45000 then Player.PlayerLevel.Value = 25 elseif Player.Exp.Value >= 50000 then Player.PlayerLevel.Value = 26 elseif Player.Exp.Value >= 57500 then Player.PlayerLevel.Value = 27 elseif Player.Exp.Value >= 65000 then Player.PlayerLevel.Value = 28 elseif Player.Exp.Value >= 72500 then Player.PlayerLevel.Value = 29 elseif Player.Exp.Value >= 82500 then Player.PlayerLevel.Value = 30 elseif Player.Exp.Value >= 100000 then Player.PlayerLevel.Value = 31 else print("An error has occured with the LevelUp Function.") end end
Basically, I want it to constantly check the Player's Exp to see if it is enough to level up.
===========================
And my second question relates to the above script, but in a different way. How would I award Exp to a player based on damage done to NPCs or Players? I want about 10 Exp awarded per 100 Damage done, but I have no idea how to do that. (The damage will be dealt with swords and bows/crossbows.) Also, 10-25 Gold should be random assigned (Player.Gold.Value), and a rare chance to get 1 or 2 gems (Player.Gems.Value) should be awarded per 300 damage or so. (The weakest NPC will have 300 damage, so you don't have to worry about stacking between NPC damage.)
Thanks!
I think you don't have to loop it , but if you will use the "While true do" Or the "Repeat" method!
-- for this script lets imagine the script is in the handle of the tool (SWORD) script.Parent.Touched:Connect(function(touched) if hit.Parent.Humanoid ~= nil then npc = hit.Parent npcHealth == hit.Parent.Humanoid.Health wait() until npcHealth = npcHealth -100 for _,v in pairs(npcHealth ) do if npcHealth == 200 then Player.Exp.Value = Player.Exp.Value + 10 else return end -- I HOPE THIS WORKS! :) end end)
I'm not sure if it works! Good luck if it does!