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 » Game Design
Home Search
 

Re: tesla script help.

Previous Thread :: Next Thread 
enser14 is not online. enser14
Joined: 28 Oct 2012
Total Posts: 258
09 Jul 2015 09:19 AM
does anyone know what i have to add to this script so that it will breakjoints to anything that touchs it. here is the script

local sp = script.Parent
local coil = sp.SecondaryCoil
local toroid = sp.Toroid
local segmentlength = 5
local varience = 5
local timetofade=.8

function raycast(spos,vec,currentdist)
local hit2,pos2=game.Workspace:FindPartOnRay(Ray.new(spos+(vec*.01),vec*currentdist),sp)
if hit2~=nil and pos2 then
if hit2.Transparency>=.5 or hit2.Name=="Handle" then
local currentdist=currentdist-(pos2-spos).magnitude
return raycast(pos2,vec,currentdist)
end
end
return hit2,pos2
end

function zap(targetpos)
if targetpos then
local m = Instance.new("Model")
m.Name = "Lightning"
local lastpos=toroid.Position
local totalsegments=math.ceil(25/segmentlength)
local direction=(targetpos-toroid.Position).unit
local struck=false
for i=1,totalsegments do
if not struck then
local entropy=Vector3.new(varience*((math.random()*2)-3),varience*((math.random()*2)-3),varience*((math.random()*2)-3))
local newpos=toroid.Position+(direction*(60*(i/totalsegments)))+entropy
local hit,endpos=raycast(lastpos,(newpos-lastpos).unit,(lastpos-newpos).magnitude)
local l=Instance.new("Part")
l.CanCollide=false
l.Anchored=true
l.Material=("Neon")
l.BrickColor=BrickColor.new("Toothpaste")
l.formFactor="Custom"
l.Size=Vector3.new(.2,.2,.2)
l.CFrame=CFrame.new(lastpos,endpos)*CFrame.Angles(math.pi/2,0,0)*CFrame.new(0,-(lastpos-endpos).magnitude/2,0)
local mesh=Instance.new("CylinderMesh")
mesh.Scale=Vector3.new(.35,(lastpos-endpos).magnitude,.35)*5
mesh.Parent=l
delay(0,function()
for i=1,timetofade/(.1) do
wait(.1)
l.Transparency=i/(timetofade/(.1))
end
end)
l.Parent=m
if hit and hit.Parent~=nil then
struck=true
local h=hit.Parent:FindFirstChild("Humanoid")
if h then
h:TakeDamage(1)
end
end
toroid.Fire:Play()
lastpos=endpos
end
end
m.Parent=game.Workspace
game:GetService("Debris"):AddItem(m,1.5)
end
end

function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 1
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:findFirstChild("Torso")
human = temp2:findFirstChild("Humanoid")
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end
end
end
return torso
end

while true do
local prob = math.random(1, 3)
local gg = findNearestTorso(toroid.Position)
if gg then
for i = 0, prob do
zap(gg.Position)
end
else
for i = 0, prob do
local xen = math.random(-600,600)
local yen = math.random(10,100)
local zen = math.random(-600,600)
local plrob = math.random(1,2)
if plrob == 1 then zap(Vector3.new(toroid.Position.X+xen,yen,toroid.Position.Z+zen)) end
end
end
wait(1)
end
Report Abuse
crazydesign is not online. crazydesign
Joined: 19 Jan 2015
Total Posts: 49
09 Jul 2015 09:35 AM
Go to scripters please.
Report Abuse
enser14 is not online. enser14
Joined: 28 Oct 2012
Total Posts: 258
09 Jul 2015 10:04 AM
this is were this is suppost to be posted q.q and i need answers not random comments ._.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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