获取 TextBox 数据并进行操作时出错 - 关闭 -
2020-5-4 21:19:36
收藏:0
阅读:291
评论:1
在开始之前,我想说的是,_控制台上没有任何类型的错误消息_。 无论如何,我一直在尝试制作一个用户工具游戏,玩家可以查看他们的头像,让自己看起来像他们,等等。 它以前在默认的 Roblox 聊天中工作得很好,但由于该聊天受到限制,我为自己的游戏制作了一个“聊天栏”。 然而,现在只有这些功能中的一个起作用(AvatarInspectMenu与UserId而不是用户名)。 你可以自己看看:
-- 客户端脚本
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(“聊天焦点”,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)
-- 服务器端脚本
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
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- Lua 虚拟机加密load(string.dump(function)) 后执行失败问题如何解决
- 我想创建一个 Nginx 规则,禁止访问
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?

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