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

Local Script works in Studio mode, but not in Play mode?

Asked by 10 years ago

This is a local script that will work when I test in studio mode, but won't when I play from the roblox website.

The whole script is:

lp=game.Players.LocalPlayer
gui=lp.PlayerGui
frame=gui.Welcome.Frame
submit=frame.submit
value=frame.value
stat=frame.stat
player=frame.player
reset=frame.reset

admins={
    ["XtremeSpy"]=workspace.ec.Value,
    ["Frostari"]=workspace.fs.Value
}
groupid=1051893
function isPlayerAdmin(p)
    for i,v in pairs(admins) do
        if p.userId==v then
            return true
        elseif p:IsInGroup(groupid) and p:GetRankInGroup(groupid) > 11 then
            return true
        end
    end
end

function checkStat(static)
    types={"Kills";"Deaths";"Points";"Demerits";"Promotion"}
    local check=static:lower()
    for i,v in pairs(types) do
        print(v)
        print(v:lower():sub(1,check:len()))
        if v:lower():sub(1,check:len())==check then
            return v
        end
    end
end

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

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

reset.MouseButton1Down:connect(function()
    for i,v in pairs(game.Players:GetPlayers()) do
        for k,val in pairs(v.leaderstats:GetChildren()) do
            if val:IsA("IntValue") then
                val.Value=0
            elseif val:IsA("StringValue") and val.Name=="Promotion" then
                val.Value="No"
            end
        end
    end
end)

But the only part that doesn't work is the, reset.MouseButton1Down:connect, on

Answer this question