获取文本框数据并对其进行操作时出错

问题描述 投票:0回答:1

开始之前,我会说控制台中没有任何类型的错误消息。无论如何,我一直在尝试制作一个用户工具游戏,让玩家可以看他们的头像,看起来像他们等等。它过去在默认的Roblox聊天中表现良好,但是由于对此进行了审核,我制作了一个“聊天栏”为我的游戏。但是,现在这些功能中只有一个起作用(AvatarInspectMenuUserId,而不是用户名)。看一下自己:

-- 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

我已经看过代码,但是似乎找不到任何问题(当然,除了尝试在Studio中进行传送外没有错误消息)。帮助将不胜感激!

lua roblox
1个回答
0
投票

如果没有错误,那么它起作用了,也许您错过了未被调用的东西,请尝试在函数中添加一些打印件,以查看是否可以打印。

© www.soinside.com 2019 - 2024. All rights reserved.