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 script from wiki edited doesn't work

Previous Thread :: Next Thread 
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
23 May 2013 06:39 PM
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
local deb = true
mouse.Button1Down:connect(function()
if deb then
deb = false
--make and do a hit test along the ray
local ray = Ray.new(tool.lol.CFrame.p, (mouse.Hit.p - tool.lol.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")
local plr = game.Players:GetPlayerFromCharacter(hit.Parent) <------------------ ONLY EDITED PARTS
if plr and plr.TeamColor == BrickColor.new("White") then <---------------------- ONLY EDITED PARTS
if humanoid then
humanoid:TakeDamage(math.random(15,30))
end
end

--draw the ray
local distance = (position - tool.lol.CFrame.p).magnitude
local rayPart = Instance.new("Part", user)
rayPart.Name = "RayPart"
rayPart.BrickColor = BrickColor:Random()
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.lol.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)
wait(0.30)
deb = true
end
end)
end)
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 06:40 PM
i love how give us no detail.

output?


also put a print at the end of every line like this

if a = 5 then print("line 1")
end print("line2")

and post the output
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
23 May 2013 06:42 PM
no output


i forgot to mention that the laser comes out if in solo
but ofcourse not in play
Report Abuse
ForceSky is not online. ForceSky
Joined: 30 Jul 2012
Total Posts: 2379
23 May 2013 06:42 PM
I tried that too, and the TakeDamage line didn't work. Just use a humanoid.Health = humanoid.health - math.random(15, 30)
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 06:42 PM
put a print at the end of every line like this

if a = 5 then print("line 1")
end print("line2")

and post the output


please
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
23 May 2013 06:49 PM
pokemon get out
learn to read
ill try the other guys solution
sorry forgot ur name by the time i pressed post
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 06:52 PM
"pokemon get out
learn to read
ill try the other guys solution
sorry forgot ur name by the time i pressed post"


uhh, it's called debuging.

and you didnt put a print on every line.
please dont tell me to get out when i am trying to help you/

Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
23 May 2013 06:55 PM
common sense
u can't see output in play
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 06:56 PM
common sense
u can't see output in play"

lol...

do it in test mode
its like tools/test/play solo


Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
23 May 2013 06:58 PM
"no output


i forgot to mention that the laser comes out if in solo
but ofcourse not in play"

OH MY GOD GET OUT ALREADY
PLEASE

lol at your face
nob
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
23 May 2013 06:58 PM
Is your script a LocalScript? (check the class name if you don't understand).

First make sure that it is a LocalScript. If so, add wait(2) to the very top of the code.
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
23 May 2013 07:01 PM
it's not a localscript and it doesn't need to be
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 07:02 PM
"OH MY GOD GET OUT ALREADY
PLEASE
"

wow.

looks like someone doesnt want help.

Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
23 May 2013 07:04 PM
exactly don't quote the rest of my post because you know your an idddd......
ok id rather not say it
but you are really... NOT SMART

Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 07:05 PM
"but you are really... NOT SMART"

says the one not trying any of the things we say you can try.



we are trying to help you idiot.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
23 May 2013 07:05 PM
"it's not a localscript and it doesn't need to be"

Aye, yes it does. If you're not willing to try things when I'm offering them, then I'm not going to continue to help.

Who told you it doesn't need to be?
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
23 May 2013 07:07 PM
explain why it needs to be a localscript
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 07:08 PM
what mrnicnac said

if you want help then dont refuse it when you get it.

also putting the print on every line helps you show how the program is running so you can see where its not working.
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
23 May 2013 07:08 PM
no output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in playno output


i forgot to mention that the laser comes out if in solo
but ofcourse not in play
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 07:10 PM
pretty sure its one of the getplayerfromcharacters or something like that in there

try making it local script to see if it works
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
23 May 2013 07:13 PM
"explain why it needs to be a localscript"

In solo you are on one client. So anything will work in server-client communication relays because there is no server will multiple clients. A normal script, in an online game, will act on the server - which means all clients too. You need a LocalScript because a mouse belongs to one client. Each client has a separate mouse - you cannot use a normal script because it would be like waiting for one mouse from the server.

A mouse does not replicate to the server and must be handled on the client (by a LocalScript).
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
23 May 2013 07:14 PM
k nic thanks
if i used tool.Activated instead of the roblox way, it wouldve worked without Localscript right
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 07:14 PM
figured it was mouse.

i dont do roblox lua anymore so im not really sure. if roblox ran on linux then i would lol.
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
23 May 2013 07:16 PM
pok sorry for going crazy
but it makes me mad when people don't read
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
23 May 2013 07:16 PM
"if i used tool.Activated instead of the roblox way, it wouldve worked without Localscript right"

Right.
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