ThrowSystem Wont Work correctly?
Asked by
6 years ago Edited 6 years ago
I made an throw script inside the rambo knife
there the throw script :
01 | local UIS = game:GetService( "UserInputService" ) |
02 | local player = game.Players.LocalPlayer |
03 | local tool = script.Parent |
05 | repeat wait() until game.Players.LocalPlayer.Character |
06 | char = game.Players.LocalPlayer.Character |
08 | local hum = char:FindFirstChild( "Humanoid" ) |
10 | local Toss = hum:LoadAnimation(script.Parent.Animations.Toss) |
11 | local Throw = hum:LoadAnimation(script.Parent.Animations.Throw) |
12 | local TossPlaying = tool:WaitForChild( "TossPlaying" ) |
14 | local mouse = player:GetMouse() |
15 | local z = tool.Handle:Clone() |
16 | local SP = script.SP:Clone() |
20 | UIS.InputBegan:Connect( function (input) |
21 | if input.UserInputType = = Enum.UserInputType.MouseButton 1 then |
22 | if ready = = false then |
25 | TossPlaying.Value = true |
32 | UIS.InputEnded:Connect( function (input) |
33 | if input.UserInputType = = Enum.UserInputType.MouseButton 1 then |
35 | script.Disabled = true |
38 | tool.Handle.Throw:Play() |
39 | TossPlaying.Value = false |
40 | local Projectile = z:Clone() |
41 | local BV = Instance.new( "BodyVelocity" ) |
42 | local BAV = Instance.new( "BodyAngularVelocity" ) |
45 | Projectile.Parent = game.Workspace |
46 | Projectile.CFrame = player.Character.Torso.CFrame*CFrame.new(math.random(- 2 , 2 ),math.random(- 1 , 1 ),- 3 ) |
47 | Projectile.CFrame = CFrame.new(Projectile.Position,mouse.hit.p) |
48 | BV.Parent = Projectile |
50 | BV.velocity = Projectile.CFrame.lookVector* 135 |
51 | BV.maxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
52 | BAV.AngularVelocity = Vector 3. new( 15 , 15 , 15 ) |
53 | BAV.MaxTorque = Vector 3. new( 4000 , 4000 , 4000 ) |
55 | SP.Parent = Projectile |
58 | tool.Handle.Transparency = 1 |
59 | tool.Server.Disabled = true |
60 | tool.Client.Disabled = true |
62 | tool.Handle.Transparency = 0 |
63 | tool.Server.Disabled = false |
64 | tool.Client.Disabled = false |
66 | script.Disabled = false |
A script named "SP" inside the throwscript
01 | script.Parent.Touched:Connect( function (hit) |
02 | local check = hit.Parent:FindFirstChildOfClass( "Humanoid" ) |
04 | local knock = Instance.new( "BodyVelocity" ) |
05 | local hitsound = Instance.new( "Sound" , script.Parent) |
10 | knock.Parent = hit.Parent.Torso |
11 | knock.maxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
12 | knock.velocity = script.Parent.CFrame.lookVector* 135 |
13 | script.Parent.Anchored = true |
14 | script.Parent.CanCollide = false |
17 | script.Disabled = false |
i want it work correctly
I need like when u hold the left mouse button it toss when up the button it throws, but mine works like: clicked = toss, click again = throw