Can someone fix this tool?
I need help making this tool, the script was made by a person in another of my questions! Thanks in advance, jakei181
01 | repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:findFirstChild( 'Head' ) and game.Players.LocalPlayer:GetMouse() |
02 | local plr = game.Players.LocalPlayer |
03 | local char = plr.Character |
05 | local mouse = plr:GetMouse() |
06 | local tool = script.Parent |
07 | local player = game:GetService( "Players" ).LocalPlayer |
09 | tool.Equipped:connect( function (mouse) |
10 | print ( "Tool equipped!" ) |
12 | mouse.Button 1 Down:connect( function () |
13 | print ( "Mouse pressed!" ) |
14 | local s,f = tool.Handle.CFrame,mouse.Hit.p |
15 | local hit,pos = workspace:FindPartOnRayWithIgnoreList(Ray.new(s,(f-s).unit* 999 ),char:children()) |
16 | local dist = (s-pos).magnitude |
19 | local newp = (CFrame.new(s,pos)*CFrame.new( 0 , 0 ,-i*(dist/ 10 ))).p+Vector 3. new(math.random(- 25 , 25 )/ 20 ,math.random(- 25 , 25 )/ 20 ,math.random(- 25 , 25 )/ 20 ) |
20 | local newdist = (lastp-newp).magnitude |
21 | local p = Instance.new( 'Part' ,char) game:service( 'Debris' ):AddItem(p,. 5 ) |
30 | p.BrickColor = BrickColor.new( 'Cyan' ) |
31 | p.Size = Vector 3. new(. 2 ,. 2 ,newdist) |
32 | p.CFrame = CFrame.new(lastp,newp)*CFrame.new( 0 , 0 ,-newdist/ 2 ) |
The tool layout is here