0
votes

I'm working on a creature-styled fighting game and have had some issues reusing tools from old Pokemon games. I've tried multiple things but in the end, the tools never do damage. They'll charge and/or shoot something, but it doesn't damage the other player. If I could get any help or ideas on what I can try, that'd be super helpful.

There's two different scripts involved, the tool script and the damage script, listed below.

Tool script:

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)

Damage script:

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)
2
Make all variables and functions hat you create local anyway. - Alexander Mashin
you've got .CanCollide set to false, then you're checking for collision... how's that gonna work? - Doyousketch2

2 Answers

0
votes

You are getting the “Considering changing it to local” error because none of the variables in the script have "local" in front of them. The script should function the same but you should still add "local" in front of those variables.

"bin = script.Parent" should be "local bin = script.Parent"

0
votes

the problem is not that you need it to be local. you may need to create a secure damage remote for this. Because of the client/server boundary you will not be able to damage others serversidedly on the client.