generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Whats missing here???

Previous Thread :: Next Thread 
LordRezmok is not online. LordRezmok
Joined: 27 Jan 2013
Total Posts: 1393
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
LordRezmok is not online. LordRezmok
Joined: 27 Jan 2013
Total Posts: 1393
27 Apr 2013 02:39 AM
bump.
Report Abuse
stephen1182 is not online. stephen1182
Joined: 31 Aug 2010
Total Posts: 4003
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
Superspeed500 is not online. Superspeed500
Joined: 22 Oct 2009
Total Posts: 452
27 Apr 2013 05:18 AM
Failing to move means that the weapon might get anchored in some way.
Report Abuse
montano60 is not online. 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 is not online. montano60
Joined: 09 Oct 2008
Total Posts: 189
27 Apr 2013 05:59 AM
Weapon* typing from phone
Report Abuse
LordRezmok is not online. LordRezmok
Joined: 27 Jan 2013
Total Posts: 1393
27 Apr 2013 03:03 PM
Thanks a ton. I think I got it now.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image