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: Laser Gun Issue

Previous Thread :: Next Thread 
WickedSiege is not online. WickedSiege
Joined: 03 Oct 2011
Total Posts: 3039
15 Jul 2014 10:24 AM
local Tool = script.Parent;
local mouse = game.Players.LocalPlayer:GetMouse()
local Down = false

enabled = true

local spark = Instance.new("Sparkles")
spark.Color = Color3.new(0,1,0)

function fire(v)

local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)

local missile = Instance.new("Part")


spark:Clone().Parent = missile

local spawnPos = vCharacter.PrimaryPart.Position

local PewPew = Tool.Handle:FindFirstChild("PewPew")

if (PewPew == nil) then
PewPew = Instance.new("Sound")
PewPew.Name = "PewPew"
PewPew.SoundId = "http://www.roblox.com/asset/?id=11944350"
PewPew.Parent = Tool.Handle
PewPew.Volume = 1
end


spawnPos = spawnPos + (v * 10)


missile.Position = spawnPos
missile.Size = Vector3.new(1,1,1)
missile.Velocity = v * 150
missile.BrickColor = BrickColor.new(1020)
missile.Shape = 0
missile.BottomSurface = 0
missile.TopSurface = 0
missile.Name = "Spark"
missile.Reflectance = .5


local force = Instance.new("BodyForce")
force.force = Vector3.new(0,98,0)
force.Parent = missile

local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = vPlayer
creator_tag.Name = "creator"
creator_tag.Parent = missile

local new_script = script.Parent.LaserBlast:clone()
new_script.Disabled = false
new_script.Parent = missile

missile.Parent = game.Workspace

PewPew:Play()

end



function gunUp()
Tool.GripForward = Vector3.new(0,.981,-.196)
Tool.GripRight = Vector3.new(1,0,0)
Tool.GripUp = Vector3.new(0,.196,.981)
end

function gunOut()
Tool.GripForward = Vector3.new(0,1,0)
Tool.GripRight = Vector3.new(1,0,0)
Tool.GripUp = Vector3.new(0,0,1)
end

function isTurbo(character)
return character:FindFirstChild("BoltHelm") ~= nil
end


function onActivated()
if not enabled then
return
end

enabled = false


local character = Tool.Parent;
local humanoid = character:WaitForChild("Humanoid")
if humanoid == nil then
print("Humanoid not found")
return
end

local targetPos = humanoid.TargetPoint
local lookAt = (targetPos - character.Head.Position).unit

local reload = .1


gunUp()
fire(lookAt)
wait(reload)
gunOut()
wait(reload)

enabled = true

end

function onEquipped()
Tool.Handle.EquipSound:play()
mouse.Button1Down:connect(function()
Down = true
while Down == true do
wait()
onActivated()
end
end)
mouse.Button1Up:connect(function()
Down = false
end)
end

script.Parent.Equipped:connect(onEquipped)


So, I turned this into a automatic gun. It works, but if you click around on the screen before you equip it, it won't fire. No output. Or vice versa if you equip it then unequip it then click around....
Report Abuse
WickedSiege is not online. WickedSiege
Joined: 03 Oct 2011
Total Posts: 3039
15 Jul 2014 10:27 AM
Btw the line I changed is near the bottom with the equipped function.
Report Abuse
WickedSiege is not online. WickedSiege
Joined: 03 Oct 2011
Total Posts: 3039
15 Jul 2014 10:31 AM
u neva help me
Report Abuse
GiraffeRaging is not online. GiraffeRaging
Joined: 12 Sep 2010
Total Posts: 1861
15 Jul 2014 10:37 AM
Line on top with the semicolon?

This isn't Javascript sir. :p
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
15 Jul 2014 11:37 AM
nub
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