So what i'm trying to do is make it where you have to be a certain level to get the Experience/Money from the mob. This is going to prevent exploiters from grinding in high level areas because they have to be to a certain level to gain the Experience/Money.
local Humanoid = script.Parent.Humanoid function PwntX_X() local tag = Humanoid:FindFirstChild("creator") if tag ~= nil then local Leaderstats = tag.Value:FindFirstChild("leaderstats") local lvl = Leaderstats:FindFirstChild("Level") if lvl == 15 then if Leaderstats ~= nil then Leaderstats.Experience.Value = Leaderstats.Experience.Value + 25 wait(0.1) script:Remove() end end end end end Humanoid.Died:Connect(PwntX_X) local Humanoid = script.Parent.Humanoid function PwntX_X() local tag = Humanoid:FindFirstChild("creator") if tag ~= nil then if tag.Value ~= nil then local Leaderstats = tag.Value:FindFirstChild("leaderstats") local lvl = Leaderstats:FindFirstChild("Level") if lvl == 15 then if Leaderstats ~= nil then Leaderstats.Money.Value = Leaderstats.Money.Value + 25 wait(0.1) script:Remove() end end end end end Humanoid.Died:Connect(PwntX_X)
You did the same function twice. I don't know why you did that I also changed the function name to a more appropriate name because when you come back to the script you might not understand it
local Humanoid = script.Parent.Humanoid local function enemyDied() local tag = Humanoid:FindFirstChild("creator") if tag ~= nil then local Leaderstats = tag:FindFirstChild("leaderstats") local lvl = Leaderstats:FindFirstChild("Level") if lvl >= 15 then -- You just checked if the level is exactly 15 but what if you're over level 15?? if Leaderstats ~= nil then Leaderstats.Experience.Value = Leaderstats.Experience.Value + 25 -- You were just removing the script.Why do this if you need it again end end end end Humanoid.Died:Connect(enemyDied)
If this answer helped you or help you find your problem then Please submit this answer