(Solved)How can I do so when I click with the mouse pointer?
Asked by
6 years ago Edited 6 years ago
Hello again, I have a problem when I often click with the mouse the string and its components are not destroyed I have to do it very slowly, I have the variable clicked on false then within the function I set it to true, the string is triggered and create the components then in elseif I have it put true and then false, I put the script there is no better method to do this?
01 | if Clicked = = false and Mouse.Target ~ = nil and character:WaitForChild( 'HumanoidRootPart' ) then |
05 | local Pos = Mouse.Hit.p |
07 | if character:FindFirstChild( 'HumanoidRootPart' ) then |
08 | local Sound = Instance.new( 'Sound' ,character:WaitForChild( 'HumanoidRootPart' )) |
15 | ancla = Instance.new( 'Part' ,workspace) |
17 | ancla.Size = Vector 3. new( 1 , 1 , 1 ) |
18 | ancla.Transparency = 1 |
20 | ancla.CanCollide = false |
21 | ancla.CFrame = CFrame.new(Pos) |
22 | Att 0 = Instance.new( 'Attachment' ,character:WaitForChild( 'HumanoidRootPart' )) |
23 | Att 1 = Instance.new( 'Attachment' ,ancla) |
24 | rope = Instance.new( 'RopeConstraint' ,character:WaitForChild( 'HumanoidRootPart' )) |
25 | rope.Color = BrickColor.new( 'Really black' ) |
27 | rope.Length = (character.Torso.Position - ancla.Position).magnitude |
28 | rope.Attachment 0 = Att 0 |
29 | rope.Attachment 1 = Att 1 |
30 | forceAncla = Instance.new( "BodyVelocity" , character:WaitForChild( 'HumanoidRootPart' )) |
31 | forceAncla.Name = "VelAncla" |
32 | while forceAncla ~ = nil and wait() do |
33 | forceAncla.MaxForce = Camera.CFrame.lookVector * Vector 3. new( 10000 , 0 , 10000 ) |
34 | forceAncla.Velocity = Camera.CFrame.lookVector * Vector 3. new( 10000 , 0 , 10000 ) |
35 | rope.Length = rope.Length - 5 |
36 | RunService.RenderStepped:Wait( 1 ) |
40 | elseif Clicked = = true then |
43 | if Att 0 and Att 1 and ancla and rope and forceAncla then |
I also put the complete script.
https://pastebin.com/730A5996