Ошибка при получении данных TextBox и манипулировании ими - ЗАКРЫТО - - PullRequest
0 голосов
/ 04 мая 2020

Прежде чем начать, скажу, что в консоли нет сообщений об ошибках любого типа . В любом случае, я пытался создать игру для пользовательских инструментов, в которой игрок мог бы посмотреть на свой аватар, выглядеть как они и т. Д. c. Раньше он хорошо работал в чате Roblox по умолчанию, но так как он модерируется, я создал «чат-бар» для своей игры. Однако теперь работает только одна из этих функций (AvatarInspectMenu с UserId, а не с именем пользователя). Посмотрите сами:

-- client script
local Players=game:GetService("Players")
local Player=Players.LocalPlayer
local StarterGui=game:GetService("StarterGui")
local GuiService=game:GetService("GuiService")
local Rep=game:GetService("ReplicatedStorage")
repeat wait(0.1) until Player.Character
local h=Player.Character:WaitForChild("Humanoid")
StarterGui:SetCore("TopbarEnabled",false)
local ChatBar=Player.PlayerGui:WaitForChild("ScreenGui").Frame.BoxFrame.Frame.ChatBar
GuiService:SetInspectMenuEnabled(false)
local CS=game:GetService("ContextActionService")
CS:BindAction("Chat Focus",function()
    ChatBar:CaptureFocus()
end,false,Enum.KeyCode.Slash)
function ID(str)
    if tonumber(str)~=nil then
        return tonumber(str)
    else
        return Rep.Idify:InvokeServer(str)
    end
end
ChatBar.FocusLost:Connect(function(entr)
    if not entr then return end
    ChatBar:ReleaseFocus(true)
    local m=ChatBar.Text
    ChatBar.Text=""
    if m=="!reset" then
        Rep.Desc:InvokeServer(Player.UserId)
    end
    if h.Sit then
        if #string.split(m," ")==1 then
            local id=ID(m)
            if h.SeatPart.Name=="AvatarInspectMenu" then
                GuiService:InspectPlayerFromUserId(id)
            end
            if h.SeatPart.Name=="Become" then
                local Desc=Rep.Desc:InvokeServer(id)
                h.Sit=false
            end
            if h.SeatPart.Name=="Tep" then
                local P,J=Rep.Join:InvokeServer(id)
                if not (P and J) then return end
                game:GetService("TeleportService"):TeleportToPlaceInstance(P,J,Player)
            end
        end
    end
end)

-- server-side script
local cache={}
local rep=game:GetService("ReplicatedStorage")
rep.Idify.OnServerInvoke=function(_,n)
    if cache[n] then return cache[n] end
    local player=game.Players:FindFirstChild(n)
    if player then
        cache[n]=player.UserId
        return player.UserId
    end
    local id
    pcall(function ()
        id=game.Players:GetUserIdFromNameAsync(n)
    end)
    if not id then return 156 end
    cache[n]=id
    return id
end
local dcs={}
rep.Desc.OnServerInvoke=function(p,n)
    if not dcs[n] then
        pcall(function()
            dcs[n]=game:GetService("Players"):GetHumanoidDescriptionFromUserId(n)
        end)
    end
    p.Character.HumanoidRootPart.CFrame=CFrame.new(0,10,0)
    if not dcs[n] then
        p.Character.Humanoid:ApplyDescription(game:GetService("Players"):GetHumanoidDescriptionFromUserId(156))
        return false
    else
        p.Character.Humanoid:ApplyDescription(dcs[n])
        return true
    end
end
rep.Join.OnServerInvoke=function(_,n)
    local id,jb=nil
    pcall(function()
        id,jb=game:GetService("TeleportService"):GetPlayerPlaceInstanceAsync(n)
    end)
    if id and jb then return id, jb else return nil end
end

Я просмотрел код, но, похоже, не могу найти никаких проблем (за исключением, конечно, отсутствия сообщения об ошибке при попытке выполнить попытку телепорт в студию). Помощь будет принята с благодарностью!

Редактировать: Этот код полностью функционален. Больше не требуется помощь! : D

1 Ответ

0 голосов
/ 04 мая 2020

Если ошибки нет, значит, она работает, возможно, вы пропустили что-то, что не было вызвано, попробуйте добавить несколько распечаток в функции, чтобы посмотреть, распечатывает ли это.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...