Knife throw script not working?
Asked by
4 years ago Edited 4 years ago
So I'm currently making a throwing knife script but when the remote server is fired an error popped up saying 20:06:36.909 - ServerScriptService.The World.Knife Throw:24: attempt to perform arithmetic (mul) on nil and number
There's a local script and a normal script
local script
01 | local plr = game:GetService( "Players" ).LocalPlayer |
03 | local rp = game:GetService( "ReplicatedStorage" ) |
04 | local KnifeThrow = rp:WaitForChild( "The World:Remotes" ):WaitForChild( "KnifeThrow" ) |
06 | local UIS = game:GetService( "UserInputService" ) |
12 | UIS.InputBegan:Connect( function (input,IsTyping) |
15 | elseif input.KeyCode = = Enum.KeyCode.T then |
16 | if workspace:FindFirstChild(plr.Name.. " Barrage" ) then |
19 | if debounce = = false then |
22 | local Character = plr.Character |
23 | local Humanoid = Character:WaitForChild( "Humanoid" ) |
25 | local pos = Character.Humanoid.TargetPoint |
26 | local LookAt = (pos - Character.Head.Position).Unit |
27 | KnifeThrow:FireServer() |
Normal script
01 | local rp = game:GetService( "ReplicatedStorage" ) |
02 | local knife = rp:WaitForChild( "The World:Remotes" ):WaitForChild( "KnifeThrow" ) |
03 | local Debris = game:GetService( "Debris" ) |
05 | local TweenService = game:GetService( "TweenService" ) |
09 | knife.OnServerEvent:Connect( function (Player,LookAt) |
10 | local Character = Player.Character |
11 | local Humanoid = Character:WaitForChild( "Humanoid" ) |
12 | local HumanoidRP = Character:WaitForChild( "HumanoidRootPart" ) |
14 | local thr = Humanoid:LoadAnimation(script:WaitForChild( "Throw" )) |
17 | local Folder = Instance.new( "Folder" ,workspace) |
18 | Folder.Name = Player.Name.. " Knives" |
21 | local knife 0 = script.Knife:Clone() |
22 | knife 0. CFrame = Character:WaitForChild( "Right Arm" ).CFrame |
23 | knife 0. Parent = Folder |
24 | knife 0. Velocity = LookAt * 30 |
25 | local fly = Instance.new( "BodyForce" ,knife 0 ) |
26 | fly.Force = Vector 3. new( 0 ,knife 0 :GetMass()* 196.2 , 0 ) |
27 | game.Debris:AddItem(knife 0 , 10 ) |
29 | knife 0. Touched:Connect( function () |