Hello, I'm making an auto-stat change script which changes someone rank when they reach a certain amount of XP, I've added a few 'end' lines because when I start a line with "if" it will make me put a 'end' at the end, I don't know if this is the problem, here is the script, the script is in a a part which is stretched across the world, so they are always touching it.
The script is in a normal script, but please help if you can!
local ting = 0
function onTouched(hit)
if ting == 0 then
ting = 1
check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local cash = stats:findFirstChild("Rank")
local xp = stats:findFirstChild("XP")
if xp.Value == 250 then
cash.Value = "Private"
elseif xp.Value == 7500 then
cash.Value = "Private First Class"
elseif xp.Value == 20000 then
cash.Value = "Corporal"
elseif xp.Value == 21550 then
cash.Value = "Warrant Officer 2"
elseif xp.Value == 23500 then
cash.Value = "Warrant Officer 1"
elseif xp.Value == 25000 then
cash.Value = "Sergeant"
elseif xp.Value == 30000 then
cash.Value = "Master Sergeant"
elseif xp.Value == 35000 then
cash.Value = "Capitan"
elseif xp.Value == 36500 then
cash.Value = "Second Lieutenant"
elseif xp.Value == 37500 then
cash.Value = "First Lieutenant"
elseif xp.Value == 40000 then
cash.Value = "Cononel"
elseif xp.Value == 45000 then
cash.Value = "Commander"
elseif xp.Value == 50000 then
cash.Value = "Admarial"
elseif xp.Value = 65000 then
cash.Value = "Commanding Officer"
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end)
ting = 0
end
end
end
script.Parent.Touched:connect(onTouched)
- THANKS

4 comments
learn indenting plox
??
one thing, you don't need an end for every elseif, just one for the first if statement
Ok