|
| 27 Apr 2013 02:29 AM |
So im makeing a raycast. The script I have lets the gun be a tool and when I click it shoots raycaasts BUT when I press it, It does not show up in my hand, I cant move, and I am laying down backwards :P Heres the script, Little help?: local tool = script.Parent local user --when the tool is equipped tool.Equipped:connect(function(mouse) --store the character of the person using the tool user = tool.Parent --when the left mouse button is clicked mouse.Button1Down:connect(function() --make and do a hit test along the ray local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit*300) local hit, position = game.Workspace:FindPartOnRay(ray, user) --do damage to any humanoids hit local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") if humanoid then humanoid:TakeDamage(30) end --draw the ray local distance = (position - tool.Handle.CFrame.p).magnitude local rayPart = Instance.new("Part", user) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("Bright red") rayPart.Transparency = 0.5 rayPart.Anchored = true rayPart.CanCollide = false rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, distance) rayPart.CFrame = CFrame.new(position, tool.Handle.CFrame.p) * CFrame.new(0, 0, -distance/2) --add it to debris so it disappears after 0.1 seconds game.Debris:AddItem(rayPart, 0.1) end) end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Apr 2013 02:46 AM |
| I just woke up, so I'm not certain this will work, but try using the KeyDown event |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2013 05:18 AM |
| Failing to move means that the weapon might get anchored in some way. |
|
|
| Report Abuse |
|
|
montano60
|
  |
| Joined: 09 Oct 2008 |
| Total Posts: 189 |
|
|
| 27 Apr 2013 05:58 AM |
| Most likely (and I posted this reply on your SAME post on the Scrpting forum) a part in the tool is anchored, causing you to be stuck while the weapin is off somewhere in workspace. |
|
|
| Report Abuse |
|
|
montano60
|
  |
| Joined: 09 Oct 2008 |
| Total Posts: 189 |
|
| |
|
|
| 27 Apr 2013 03:03 PM |
| Thanks a ton. I think I got it now. |
|
|
| Report Abuse |
|
|