(Roblox LUA Scripting) "Considering changing it to local"?

我正在制作一款以生物为主题的格斗游戏,但无法重复使用旧版 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)
点赞
用户14167391
用户14167391

你收到了“考虑更改为本地”的错误提示,因为脚本中的变量都没有在前面加上“local”。该脚本应该能够正常工作,但你仍然应该在这些变量前面加上“local”。

“bin = script.Parent” 应该改为“local bin = script.Parent”。

2020-11-02 19:59:29
用户14662604
用户14662604

问题不在于您需要它是本地的。您可能需要为此创建一个安全的有害远程方法。由于客户端/服务器边界,您将无法在客户端上对其他人造成服务器方面的损害。

2020-11-18 14:29:18