(Roblox LUA Scripting) "Considering changing it to local"?
2020-10-30 8:17:13
收藏:0
阅读:102
评论:2
我正在制作一款以生物为主题的格斗游戏,但无法重复使用旧版 Pokemon 游戏中的工具。我尝试过多种方法,但最终这些工具都无法对其他玩家造成伤害。如果有任何帮助或者想法,请告诉我。
有两个不同的脚本需要,工具脚本和伤害脚本,如下所示。
工具脚本:
01 bin = script.Parent
02 me = script.Parent.Parent.Parent
03
04 enabled = true
05
06 function onButton1Down(mouse)
07 if not enabled then
08 return
09 end
10
11 local player = game.Players.LocalPlayer
12 if player == nil then return end
13 enabled = false
14
15
16 mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
17
18 t = me.Character:findFirstChild("Torso")
19 if t ~= nil then
20
21 hax = game.Lighting.LeafBlade1:clone()
22 hax.Parent = t
23 wait(0.05)
24 p = Instance.new("Part")
25 p.Parent = game.Workspace
26 p.CanCollide = false
27 p.Transparency = 1
28 p.CFrame = me.Character.Torso.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 0)
29 d = Instance.new("BodyVelocity")
30 d.Parent = me.Character.Torso
31 d.maxForce = Vector3.new(math.huge, math.huge, math.huge)
32 d.velocity = p.CFrame.lookVector * 100
33 me.Character.Torso.CFrame = me.Character.Torso.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 0)
34 wait(0.15)
35
36 d:Remove()
37 p:Remove()
38 wait(0.1)
39 hax:Remove()
40
41 wait(3)
42 mouse.Icon = "rbxasset://textures\\GunCursor.png"
43 enabled = true
44
45 end
46 end
47
48
49 function onS(mouse)
50 mouse.Button1Down:connect(function() onButton1Down(mouse) end)
51 end
52 bin.Selected:connect(onS)
伤害脚本:
01 function onTouched(hit)
02 humanoid = hit.Parent.Parent:findFirstChild("Humanoid")
03 if humanoid ~= nil then
04 if humanoid.Parent ~= script.Parent.Parent then
05 humanoid.Health = humanoid.Health - 20
06 hit.CFrame = hit.CFrame * CFrame.fromEulerAnglesXYZ(-0.4, 0, 0)
07 for i = 1 , 1 do
08 p = Instance.new("Part")
09 p.Parent = game.Workspace
10 p.CanCollide = false
11 p.BrickColor = BrickColor.new(21)
12 p.Size = Vector3.new(1, 1, 1)
13 p.TopSurface = "Smooth"
14 p.BottomSurface = "Smooth"
15 p.CFrame = hit.CFrame
16 p.Velocity = Vector3.new(math.random(-50, 50), math.random(30, 50), math.random(-50, 50))
17 d = Instance.new("SpecialMesh")
18 d.Parent = p
19 d.MeshType = "Brick"
20 d.Scale = Vector3.new(0.2, 0.2, 0.2)
21 game:GetService("Debris"):AddItem(p,5)
22 end
23 end
24 end
25 end
26 script.Parent.Touched:connect(onTouched)
点赞
用户14662604
问题不在于您需要它是本地的。您可能需要为此创建一个安全的有害远程方法。由于客户端/服务器边界,您将无法在客户端上对其他人造成服务器方面的损害。
2020-11-18 14:29:18
评论区的留言会收到邮件通知哦~
推荐文章
- 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”。该脚本应该能够正常工作,但你仍然应该在这些变量前面加上“local”。
“bin = script.Parent” 应该改为“local bin = script.Parent”。