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: Basic weapon script won't fire

Previous Thread :: Next Thread 
Wakarimasu is not online. Wakarimasu
Joined: 12 Nov 2013
Total Posts: 1448
27 Nov 2013 12:14 PM
So I was making this and it won't work. No output, the B1D function won't work is all.

rktsc = wep.Rocket
handle = wep.Handle
propel = wep.RocketPropulsion
rdy = true
enabled = false

wep.Equipped:connect(function()
local char = wep.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
enabled = true
mouse = plr:GetMouse()
print("Equipped")
end)

wep.Unequipped:connect(function()
enabled = false
mouse = nil
print("Unequipped")
end)

if enabled then
mouse.Button1Down:connect(function()
if rdy then
print("Ready")
rdy = false
local rkt = Instance.new("Part", Workspace)
rkt.Position = Handle.Position
rkt.BrickColor = BrickColor.new("Medium stone grey")
rkt.FormFactor = Enum.FormFactor.Custom
rkt.Size = Vector3.new(1,1,1)
rkt.Material = "CorrodedMetal"
rkt.CanCollide = false
local propc = propel:Clone()
propc.Parent = rkt
propc.Target = mouse.Hit
print("Propelling")
local rocketc = rktsc:Clone()
rocketc.Parent = rkt
rocketc.Disabled = false
print("Making a rocket")
print("Fired")
wait(1)
tool:Destroy()
print("Done")
elseif not rdy then
end
end)
end
Report Abuse
Wakarimasu is not online. Wakarimasu
Joined: 12 Nov 2013
Total Posts: 1448
27 Nov 2013 12:14 PM
It prints Equipped and Unequipped but nothing past that.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
27 Nov 2013 12:16 PM
Because it onky checks once. Try putting it in the Equipped event, because it returns a mouse.
Report Abuse
Wakarimasu is not online. Wakarimasu
Joined: 12 Nov 2013
Total Posts: 1448
27 Nov 2013 12:57 PM
Did some tweaking. Now it makes the rocket but it won't go forward. It also fires when it's unequipped.

wep = script.Parent
rktsc = wep.Rocket
handle = wep.Handle
propel = wep.RocketPropulsion
rdy = true
enabled = false

wep.Equipped:connect(function()
local char = wep.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
enabled = true
mouse = plr:GetMouse()
print("Equipped")
if enabled and rdy then
mouse.Button1Down:connect(function()
print("Ready")
rdy = false
local rkt = Instance.new("Part", Workspace)
rkt.Position = handle.Position
rkt.BrickColor = BrickColor.new("Medium stone grey")
rkt.FormFactor = Enum.FormFactor.Custom
rkt.Size = Vector3.new(1,1,1)
rkt.Material = "CorrodedMetal"
rkt.CanCollide = false
local propc = propel:Clone()
propc.Parent = rkt
propc.Target = mouse.Hit
propc:Fire()
print("Propelling")
local rocketc = rktsc:Clone()
rocketc.Parent = rkt
rocketc.Disabled = false
print("Making a rocket")
print("Fired")
wait(1)
wep:Destroy()
print("Done")
end)
elseif not rdy then
end
end)

wep.Unequipped:connect(function()
enabled = false
mouse = nil
print("Unequipped")
end)


I've tried mouse.Hit and mouse.Hit.p

And it fires when it's unequipped :\
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