Whenever I run this script and type in all the variables, the script breaks and doesn't output an error message. Any help or suggestions?

frame=script.Parent
lp=game.Players.LocalPlayer
submit=frame.submit
value=frame.value
stat=frame.stat
player=frame.player
admins={
	["XtremeSpy"]=workspace.ec.Value, --Int Value
	["Frosty"]=workspace.fs.Value --Number Value
}
groupid=0 --I changed it to be anonymous 
function isPlayerAdmin(p)
	for i,v in pairs(admins) do
		if p.userId==v or p.Name=="Player1" then --Player1 to studio test it
			return true
		elseif p:IsInGroup(groupid) and p:GetRankInGroup(groupid) > 11 then
			return true
		else
			return false
		end
	end
end

function checkStat(stat)
	types={
		"Kills","Deaths","Points","Demerits","Promotion" --Promotion is Bool Value the Rest are int values
	}
	local check=stat:lower()
	for key,value in pairs(types) do
		if value:sub(1,check:len()):lower()==check then
			return value
		else 
			return false
		end
	end
end

function getP(name)
    local p1 = name:lower()
	for i,v in pairs(game.Players:GetPlayers()) do
    	if string.sub(v.Name:lower(),1, string.len(p1)) == p1 then
    		return v
		else
			return false
    	end
	end
end

submit.MouseButton1Down:connect(function()
	if isPlayerAdmin(lp) == true then
		if string.len(value.Text) > 1 and string.len(stat.Text) > 1 and string.len(player.Text) > 1 then
			if tonumber(value.Text) ~= nil and checkStat(stat.Text)~=false and getP(player.Text)~=false then
				local vlu=tonumber(value.Text):match("%d+")
				local sts=checkStat(stat.Text)
				local plyr=getP(player.Text)
				game.Players[plyr].leaderstats[sts].Value=vlu
			elseif tonumber(value.Text)==nil and checkStat(stat.Text)~=false and getP(player.Text)~= false then
				if value.Text:lower()=="yes" or value.Text:lower()=="no" then
					local vlu=value.Text
					local sts="Promotion"
					local plyr=getP(player.Text)
					plyr.leaderstats[sts].Value=vlu
				end
			end
		end
	end
end)

3 comments

0

Which part of the script do you think is having problems? Or where does it stop working?

0

I don't know what part it's at but after I click submit it doesn't change any of the leaderstat values. @LordDragonZord

0

@LordDragonZord It could possibly be the finding the player part of it though.