获取 TextBox 数据并进行操作时出错 - 关闭 -

在开始之前,我想说的是,_控制台上没有任何类型的错误消息_。 无论如何,我一直在尝试制作一个用户工具游戏,玩家可以查看他们的头像,让自己看起来像他们,等等。 它以前在默认的 Roblox 聊天中工作得很好,但由于该聊天受到限制,我为自己的游戏制作了一个“聊天栏”。 然而,现在只有这些功能中的一个起作用(AvatarInspectMenuUserId而不是用户名)。 你可以自己看看:

-- 客户端脚本
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”,falselocal ChatBar=Player.PlayerGui:WaitForChild(“ScreenGui”).Frame.BoxFrame.Frame.ChatBar
GuiService:SetInspectMenuEnabled(false)
local CS=game:GetService(“ContextActionService”)
CS:BindAction(“聊天焦点”,function()
    ChatBar:CaptureFocus()
endfalse,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-- 服务器端脚本
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 中尝试进行传送时,当然没有错误消息)。 非常感谢你的帮助!

编辑:这个代码是完全功能的。 不需要更多的帮助! :D

点赞
用户13461896
用户13461896

如果没有错误,那就可以工作了,也许你漏掉了一些没有调用的东西,请尝试在函数中添加一些打印语句,看看是否能打印出来。

2020-05-04 20:30:49