HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
|
| 18 Jan 2013 07:30 PM |
Attempted to make a quick script with the wiki raycasted gun example, however, when I have the CFrame occur, nothing happens, but it prints out the line below it.
tool = script.Parent local user visual = tool.Handle --when the tool is equipped tool.Equipped:connect(function(mouse) --store the character of the person using the tool user = tool.Parent location = user.Torso.Position --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)
mouse.Button2Down:connect(function() --do stuff for ADS visual.CFrame = CFrame.new(location.x + 1, location.y, location.z) print("ADS")
end)
end) Any idea of whats wrong? |
|
|
| Report Abuse |
|
|
HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
| |
|
HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
| |
|
HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
| |
|
HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
| |
|
HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
| |
|
HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
| |
|
HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
| |
|
8SunTzu8
|
  |
| Joined: 30 Sep 2011 |
| Total Posts: 8199 |
|
|
| 19 Jan 2013 09:31 AM |
Surprised nobody tried helping.
I put the script in a tool with just a "Handle" brick, and the script is in a local script. The tool is named Gun. I tested it, and it works fine when I fire it. What is the output on your end?
"If you want to become a Developer or Innovator for CSA, contact me." |
|
|
| Report Abuse |
|
|
HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
|
| 19 Jan 2013 09:33 AM |
| My output from this is just it printing "ADS" on rightclick, may be due to fact that this is in regular script? |
|
|
| Report Abuse |
|
|
8SunTzu8
|
  |
| Joined: 30 Sep 2011 |
| Total Posts: 8199 |
|
|
| 19 Jan 2013 09:52 AM |
Oh, yeah, print("ADS") is all that shows on mine.
I don't know about the CFraming.
visual.CFrame = CFrame.new(location.x + 1, location.y, location.z) I am guessing that this is the line.
"location.x" I believe is read only... but it looks like you're just referencing the value.
Perhaps instead...
visual.CFrame = CFrame.new(visual.Position) + Vector3.new(1,0,0)
I don't work with CFrames that often.
"If you want to become a Developer or Innovator for CSA, contact me." |
|
|
| Report Abuse |
|
|
HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
|
| 19 Jan 2013 09:56 AM |
| Tried puttting it in a local script, but same thing happened. |
|
|
| Report Abuse |
|
|
8SunTzu8
|
  |
| Joined: 30 Sep 2011 |
| Total Posts: 8199 |
|
|
| 19 Jan 2013 09:59 AM |
tool.GripPos = Vector3.new(0,0,1)
I don't know what you're trying to do, but if that does it, then perhaps you can toy with it.
Are you trying to zoom in?
"If you want to become a Developer or Innovator for CSA, contact me." |
|
|
| Report Abuse |
|
|
HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
|
| 19 Jan 2013 10:02 AM |
| Might work, I'm try to make the gun shift to a more central position on Right click, like aiming down sights. |
|
|
| Report Abuse |
|
|
8SunTzu8
|
  |
| Joined: 30 Sep 2011 |
| Total Posts: 8199 |
|
|
| 19 Jan 2013 10:05 AM |
Yeah, then editing the grip might work, but it will look funny if you don't edit the arms too.
"If you want to become a Developer or Innovator for CSA, contact me." |
|
|
| Report Abuse |
|
|
HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
|
| 19 Jan 2013 01:00 PM |
Figured out it works with using GripPos, however, using the code below, it will switch position once, however, the second time, when I try and switch it back out of ADS mode, it just stops working, with no errors in output.
mouse.Button2Down:connect(function() --do stuff for ADS if ADS == false then tool.GripPos = Vector3.new(1.5,0,0) ADS = true print("ADS") wait(1) else if ADS == false then tool.GripPos = Vector3.new(0,0,0) ADS = false print("No ADS") wait(1) end end end) |
|
|
| Report Abuse |
|
|
8SunTzu8
|
  |
| Joined: 30 Sep 2011 |
| Total Posts: 8199 |
|
|
| 19 Jan 2013 01:06 PM |
local ADS = false
mouse.Button2Down:connect(function() --do stuff for ADS if ADS == false then tool.GripPos = Vector3.new(1.5,0,0) ADS = true print("ADS") wait(1) else tool.GripPos = Vector3.new(0,0,0) ADS = false print("No ADS") wait(1) end end)
You did "if DS == false then" in both parts.
"If you want to become a Developer or Innovator for CSA, contact me." |
|
|
| Report Abuse |
|
|
HD188753
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 5021 |
|
| |
|
8SunTzu8
|
  |
| Joined: 30 Sep 2011 |
| Total Posts: 8199 |
|
|
| 19 Jan 2013 01:54 PM |
I hope it's working, and I am glad that I could help.
"If you want to become a Developer or Innovator for CSA, contact me." |
|
|
| Report Abuse |
|
|