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: Automatic Raycast gun...

Previous Thread :: Next Thread 
ThePyromaticBeast is not online. ThePyromaticBeast
Joined: 26 Dec 2012
Total Posts: 197
03 Jan 2013 02:13 PM
How do script one? I see the one of the wiki, and i understand that one.. But.. Not an automatic one.. Also.. How do i do ammo on a gun too?
Report Abuse
ThePyromaticBeast is not online. ThePyromaticBeast
Joined: 26 Dec 2012
Total Posts: 197
03 Jan 2013 02:17 PM
....?
Report Abuse
Xtreme101 is not online. Xtreme101
Joined: 03 Jan 2009
Total Posts: 4385
03 Jan 2013 02:19 PM
Scripting Helpers, not Scripting Slaves. Get lost.
Report Abuse
ThePyromaticBeast is not online. ThePyromaticBeast
Joined: 26 Dec 2012
Total Posts: 197
03 Jan 2013 02:40 PM
.... I was asking for help thank you very much... And.. Is it while mousebutton1 and it firing? Or.. Is it couroutines?
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
03 Jan 2013 02:41 PM
.....It should be as simple as making while loop that does firing until you release left mouse button.
Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
03 Jan 2013 02:44 PM
Yep, coroutines.

local firing = false

mouse.Button1Down:connect(function()
firing = true
end)

mouse.Button1Up:connect(function()
firing = false
end)

coroutine.resume(coroutine.create(function()
while wait(1) do
if firing then
--Fire bullets here
end
end
end))
Report Abuse
ThePyromaticBeast is not online. ThePyromaticBeast
Joined: 26 Dec 2012
Total Posts: 197
03 Jan 2013 02:44 PM
Just curious... >_>
Report Abuse
ThePyromaticBeast is not online. ThePyromaticBeast
Joined: 26 Dec 2012
Total Posts: 197
05 Jan 2013 07:54 PM
This is what i got so far..



Main firing script;


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
while true do
wait(.3)
--make and do a hit test along the ray
local ray = Ray.new(tool.Barrel.CFrame.p, (mouse.Hit.p - tool.Barrel.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(10)
end

--draw the ray
local distance = (position - tool.Barrel.CFrame.p).magnitude
local rayPart = Instance.new("Part", user)
rayPart.Name = "RayPart"
rayPart.BrickColor = BrickColor.new("Bright red")
rayPart.Transparency = 0.3
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.1, 0.1, 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)



Local gui script;



local Tool = script.Parent;



--wait(.5)
--mouse.Icon = "rbxasset://textures\\GunCursor.png"
--enabled = true
--mouse.Button1Up:connect(function() onButton1Up(mouse) end)


Tool.Enabled = false

function onButton1Up(mouse)
Tool.Script.Disabled = true
Tool.Enabled = false
wait(2.2)
end
function onButton1Down(mouse)
Tool.Script.Disabled = false
Tool.Enabled = true
end
function onEquippedLocal(mouse)

if mouse == nil then
print("Mouse not found")
return
end

mouse.Icon = "rbxasset://textures\\GunCursor.png"
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
mouse.Button1Up:connect(function() onButton1Up(mouse)end)
end


Tool.Equipped:connect(onEquippedLocal)



This works fine in studio-visit mode.. But.. It doesn't work on online places..
Report Abuse
ThePyromaticBeast is not online. ThePyromaticBeast
Joined: 26 Dec 2012
Total Posts: 197
05 Jan 2013 08:11 PM
...? I really have no clue.. >_>
Report Abuse
ThePyromaticBeast is not online. ThePyromaticBeast
Joined: 26 Dec 2012
Total Posts: 197
05 Jan 2013 08:37 PM
..?
Report Abuse
ThePyromaticBeast is not online. ThePyromaticBeast
Joined: 26 Dec 2012
Total Posts: 197
05 Jan 2013 08:45 PM
Help...........? -_-""
Report Abuse
ThePyromaticBeast is not online. ThePyromaticBeast
Joined: 26 Dec 2012
Total Posts: 197
06 Jan 2013 02:01 AM
.....................................................................................................................................................................................................................................................................................................
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
06 Jan 2013 02:02 AM
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu==pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Report Abuse
ThePyromaticBeast is not online. ThePyromaticBeast
Joined: 26 Dec 2012
Total Posts: 197
07 Jan 2013 06:30 PM
-_-" Sad that only a troll can answer me.. How about some scripters, eh?
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