Leaderstats无法正常工作?还是没有检测到点击?
2020-6-20 23:16:27
收藏:0
阅读:187
评论:1
我正在尝试制作Roblox上的模拟器游戏,但我似乎无法使领袖统计数据工作,或者它确实工作,而我的点击事件无法正常工作,我只是遵循脚本教程,所以我一无所知。这是我的Remotes脚本,其中打印的内容是"IS THIS WORKING",这是为了查看问题所在。基本上,那个不运行,或者有另一个问题阻止它运行,至少我这么认为。我有其他的脚本,我会放一些我认为可能是必要的,但是如果您需要更多,请随时问我。
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteData = game:GetService("ServerStorage"):WaitForChild("RemoteData")
local cooldown = 1
print("IS THIS WORKING")
replicatedStorage.Remotes.Lift.OnServerEvent:Connect(function(player)
if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end
local debounce = remoteData[player.Name].Debounce
if not debounce then
debounce.Value = true
player.leaderstats.Stealth.Value = player.leaderstats.Stealth.Value + 25 *(player.leaderstats.Rebirths.Value + 1)
wait(cooldown)
debounce.Value = false
end
统计数据
local serverStorage = game:GetService("ServerStorage")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local stealth = Instance.new("NumberValue")
stealth.Name = "Stealth"
stealth.Parent = leaderstats
local rebirths = Instance.new("IntValue")
rebirths.Name = "Rebirths"
rebirths.Parent = leaderstats
local Folder = Instance.new("Folder")
Folder.Name = player.Name
Folder.Parent = serverStorage.RemoteData
local debounce = Instance.new("BoolValue")
debounce.Name = "Debounce"
debounce.Parent = Folder
end)
模块脚本
local module = {}
local replicatedStorage = game:GetService("ReplicatedStorage")
function module.Lift()
replicatedStorage.Remotes.Lift:FireServer()
end
return module
本地脚本
local module = require(script.Parent:WaitForChild("ModuleScript"))
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
script.Parent.Activated:Connect(function()
module.Lift()
end)
对于我的Explorer结构,请单击 这里
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- 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 代码?

local remoteData = game:GetService("ServerStorage"):WaitForChild("RemoteData")你的问题是等待一个子对象时它会暂停脚本直至找到 RemoteData,
接着,在脚本中,它将检查 RemoteData 是否为空。
if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end有两个解决方法: 第一个解决方法是添加最大等待时间以防找不到 RemoteData 而脚本始终暂停(仅在脚本开始运行后添加 RemoteData 时有用)。
第二个解决方法是用
FindFirstChild替换WaitForChild,它将立即检查而不需要等待。我推荐的解决方法是
local remoteData = game:GetService("ServerStorage"):FindFirstChild("RemoteData")备选的解决方法是,如果你在脚本开始后添加了 RemoteData ,想要进行二次检查
local remoteData = game:GetService("ServerStorage"):WaitForChild("RemoteData",20)请确定是否有效,因为我花了一段时间才想出这个解决方案。