(Roblox LUA脚本)“;考虑将其改为“本地”吗;?
我正在开发一款生物风格的格斗游戏,在重用旧口袋妖怪游戏中的工具时遇到了一些问题。我尝试过多种方法,但最终,这些工具不会造成损坏。他们会冲锋和/或射击,但不会伤害其他玩家。如果我能得到任何帮助或想法,我可以尝试,那将是非常有用的 下面列出了两种不同的脚本,工具脚本和损坏脚本 工具脚本:(Roblox LUA脚本)“;考虑将其改为“本地”吗;?,lua,roblox,Lua,Roblox,我正在开发一款生物风格的格斗游戏,在重用旧口袋妖怪游戏中的工具时遇到了一些问题。我尝试过多种方法,但最终,这些工具不会造成损坏。他们会冲锋和/或射击,但不会伤害其他玩家。如果我能得到任何帮助或想法,我可以尝试,那将是非常有用的 下面列出了两种不同的脚本,工具脚本和损坏脚本 工具脚本: 01 bin = script.Parent 02 me = script.Parent.Parent.Parent 03 04 enabled = true 05 06 function on
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)
您将得到“考虑将其更改为本地”错误,因为脚本中的变量前面都没有“本地”变量。脚本的功能应该是相同的,但仍然应该在这些变量前面添加“local”
“bin=script.Parent”应该是“local bin=script.Parent”问题不在于您需要它是本地的。您可能需要为此创建一个安全的损坏遥控器。由于客户端/服务器边界,您将无法在客户端服务器端损坏其他变量。将您创建的所有变量和函数设置为本地。
.CanCollide
设置为false,然后检查冲突。。。那怎么办?把它们换成本地的,但是没什么变化,工具仍然没有损坏。我试着摆弄它来添加安全损坏遥控器,但没有用。有什么想法吗?