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

My goal is to give 5 exp to my exp bar that i made once the npc is killed, any help please?

Asked by 4 years ago
Edited 4 years ago

I wish to add 5 exp to my exp bar once the npc is killed. this is the script to change the text when exp is received:

local player = game.Players.LocalPlayer local exp = player:WaitForChild("leaderstats"):WaitForChild("Exp") local axp = player:WaitForChild("leaderstats"):WaitForChild("ExpNeeded")

while true do wait() script.Parent.Text = "EXP: " .. exp.Value .. "/" .. axp.Value end And this is the script for the bar changing once the exp is gained:

local player = game.Players.LocalPlayer local exp = player:WaitForChild("leaderstats"):WaitForChild("Exp") local axp = player:WaitForChild("leaderstats"):WaitForChild("ExpNeeded")

while true do wait() local expBarSize = (exp.Value/axp.Value) - 0.02 if exp.Value == 0 then expBarSize = 0 script.Parent:TweenSize(UDim2.new(expBarSize, 0, 0, 20), "Out", "Linear", 0.25) else script.Parent:TweenSize(UDim2.new(expBarSize, 0, 0, 20), "Out", "Linear", 0.25) end end

and this is the script for leveling up once exp reaches a certain amount:


--GetLevel Script (Local Script) local player = game.Players.LocalPlayer local level = player:WaitForChild("leaderstats"):WaitForChild("Level")

script.Parent.Text = "Current Level: " .. level.Value

level.Changed:Connect(function(value) script.Parent.Text = "Current Level: " .. value end)

oh and I may of also made a mistake on which one functions which because i forgot to rename them once i made them, Sorry!

0
Oh and sorry i have no idea how to use this website so i didn't make the script thing the_waterpearl1 0 — 4y
0
your script is scary DesiredRep 75 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

I think this answers what you are asking. You will need to figure out the player who killed the NPC and assign it to the playerWhoKilled variable

--This would go in the script that handles the killing of the NPC

local playerWhoKilled --Player who killed the NPC.
local xpDrop = 5

playerWhoKilled:WaitForChild("leaderstats"):WaitForChild("Exp").Value += xpDrop
Ad

Answer this question