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: Mouse

Previous Thread :: Next Thread 
jimmybolt77 is not online. jimmybolt77
Joined: 06 Jul 2008
Total Posts: 292
21 Jun 2012 03:44 PM
Apparently output says something when the function has mouse as a variable. I made a comment saying where it is

Players.Player.Backpack.Gourd.Script:19: attempt to index local 'mouse' (a nil value)


local player=game.Players.LocalPlayer
local char=player.Character

function Stream(mouse)
local b=Instance.new("Part")
b.BrickColor= BrickColor.new("Bright red")
b.Reflectance=0
b.Transparency=1
b.Size=Vector3.new(2,2,2)
b.Shape="Ball"
b.CanCollide=false
b.TopSurface="Smooth"
b.Position=char.Head.Position
b.BottomSurface="Smooth"
b.Friction=0
b.Touched:connect(function(h) Hit(h) end)
local bo=Instance.new("BodyVelocity")
bo.maxForce=Vector3.new(9999,9999,9999)
bo.velocity=(mouse.Hit.p-char.Head.Position).unit*60 --Problem over here
bo.Parent=b
b.Parent=Gourd
local Bo=b
while Bo.Parent and Up==false do
wait()
if mouse.Target and (Bo.Position-mouse.Target.Position).magnitude<7 then
Hit(mouse.Target)
else
Bo.CFrame=b.CFrame
bo.velocity=(mouse.Hit.p-Bo.Position).unit*150
end
local b=Instance.new("Part")
b.BrickColor=Color
b.Reflectance=0
b.Transparency=0.2
b.Touched:connect(Hit)
b.Size=Vector3.new(2,2,2)
b.CanCollide=false
b.Anchored=true
b.TopSurface="Smooth"
b.Parent=Gourd
b.CFrame=Bo.CFrame*CFrame.Angles(math.rad(math.random(0,360)),math.rad(math.random(0,360)),math.rad(math.random(0,360)))
b.BottomSurface="Smooth"
Delay(0,function()
local p=b
for i=1,5 do
wait(0.05)
p.Transparency=i/5
end
p:remove()
end)
end
pcall(function() Bo:remove() end)
end


script.Parent.Selected:connect(function(mouse)
mouse.Button1Down:connect(Stream)
end)
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
21 Jun 2012 03:48 PM
script.Parent.Selected:connect(function(mouse)
mouse.Button1Down:connect(function() Stream(mouse) end)
end)
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
21 Jun 2012 03:49 PM
script.Parent.Selected:connect(function(mouse)
mouse.Button1Down:connect(function() Stream(mouse) end)
end)
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
21 Jun 2012 03:50 PM
@zars
Y U EARLY POST?!
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
21 Jun 2012 03:51 PM
I laik to nom on late toast
Report Abuse
jimmybolt77 is not online. jimmybolt77
Joined: 06 Jul 2008
Total Posts: 292
21 Jun 2012 04:03 PM
This is supposed to make a brick and follow the mouse around, but noting happens, and output says nothing. When I press down the mouse it should work and when I let go it should disappear. Help?

local player=game.Players.LocalPlayer
local char=player.Character
Up = false

function Stream(mouse)
local b=Instance.new("Part")
b.BrickColor= BrickColor.new("Bright red")
b.Reflectance=0
b.Transparency=1
b.Size=Vector3.new(2,2,2)
b.Shape="Ball"
b.CanCollide=false
b.TopSurface="Smooth"
b.Position=char.Head.Position
b.BottomSurface="Smooth"
b.Friction=0
b.Touched:connect(function(h) Hit(h) end)
local bo=Instance.new("BodyVelocity")
bo.maxForce=Vector3.new(9999,9999,9999)
bo.velocity=(mouse.Hit.p-char.Head.Position).unit*60 --Right here
bo.Parent=b
b.Parent=Gourd
local Bo=b
while Bo.Parent and Up==false do
wait()
if mouse.Target and (Bo.Position-mouse.Target.Position).magnitude<7 then
Hit(mouse.Target)
else
Bo.CFrame=b.CFrame
bo.velocity=(mouse.Hit.p-Bo.Position).unit*150
end
local b=Instance.new("Part")
b.BrickColor=Color
b.Reflectance=0
b.Transparency=0.2
b.Touched:connect(Hit)
b.Size=Vector3.new(2,2,2)
b.CanCollide=false
b.Anchored=true
b.TopSurface="Smooth"
b.Parent=Gourd
b.CFrame=Bo.CFrame*CFrame.Angles(math.rad(math.random(0,360)),math.rad(math.random(0,360)),math.rad(math.random(0,360)))
b.BottomSurface="Smooth"
Delay(0,function()
local p=b
for i=1,5 do
wait(0.05)
p.Transparency=i/5
end
p:remove()
end)
end
pcall(function() Bo:remove() end)
end


script.Parent.Selected:connect(function(mouse)
mouse.Button1Down:connect(function() Stream(mouse) end)
end)


function Hit(p)
if p.Parent.Name~=Name and p.Parent.Parent.Name~=Name and p.Name~="Base" and p.Name~="Sand" and p.Parent then
Delay(0,function()
p.Anchored=true
p.Name="Sand"
p.BrickColor=Color
for i=1,5 do
p.Transparency=i/5
wait(0.1)
end
p:remove()
end)
end
end
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
21 Jun 2012 04:05 PM
I think you can't use mouse object outside Selected/Equipped function.
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