Why isn't hole a valid member of tool?
Asked by
6 years ago Edited 6 years ago
Im trying to make a gun to my game, and i made this script:
02 | local pistola = script.Parent |
03 | local hole = pistola.Hole |
04 | local mouse = game.Players.LocalPlayer:GetMouse() |
10 | local headshotDamage = 50 |
18 | pistola.Equipped:Connect( function () |
22 | pistola.Unequipped:Connect( function () |
27 | pistola.Activated:Connect( function () |
30 | pistola.Handle.Disparo:Play() |
31 | local bullet = Instance.new( "Part" ) |
32 | bullet.Size = Vector 3. new(range, 0.25 , 0.25 ) |
33 | local ray = Ray.new(hole.CFrame.Position, (mouse.Hit.Position - hole.CFrame.Position).Unit*range) |
34 | local hit, position = workspace:FindPartOnRay(ray, game.Players.LocalPlayer.Character) |
35 | local distance = (pistola.Handle.CFrame.p - position).magnitude |
36 | bullet.CFrame = CFrame.new(pistola.Handle.CFrame.p, position) * CFrame.new( 0 , 0 , distance/ 2 ) |
37 | bullet.Transparency = 0.5 |
38 | bullet.CanCollide = false |
39 | bullet.Anchored = true |
40 | bullet.Parent = game.Workspace |
41 | bullet.Orientation = hole.Orientation |
42 | bullet.Position = hole.Position |
43 | game:GetService( "Debris" ):AddItem(bullet, 0.5 ) |
Ignore the parts were i speak portuguese :P
But then i start recieving this error:
18:30:18.806 - Hole is not a valid member of Tool
idk what's happening, could you pls help me?
Also send a real answer, not a comment.