Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't this script work?

Asked by
Avectus 120
9 years ago

I'm trying to make a standard lightsaber but I'm having difficulty with the sheathing of the saber (the laserblade part).

The code below is inside a localscript which is in the lightsaber tool itself.

-- Numeric Variables
local NumValue = script.Parent.Value.Value
local v = 5, 1, -1

-- Ignition Key
Mouse.KeyDown:connect(function(k) 
k = k:lower() 
if k == "q" then 
    if NumValue == 1 then
NumValue = 2
Saber.Transparency = 0
Saber2.Transparency = 0.5
PointLight.Enabled = true

for i = 1, 5 do
      SaberM.Scale = Vector3.new(0.25, 1*i, 0.25)  SaberM.Offset = Vector3.new(0, 0.24, -0.86*i)
      wait()                                       
      SaberM2.Scale =  Vector3.new(0.3, 1.01*i, 0.3) SaberM2.Offset = Vector3.new(0,0.24,-0.86*i)
      wait()
end
else
    NumValue = 1
for i = 1, 5 do
 SaberM.Scale = Vector3.new(0.25, v, 0.25)  SaberM.Offset = Vector3.new(0, 0.24, -103.2/i)
      wait()                                       
      SaberM2.Scale =  Vector3.new(0.3, 121.2/i, 0.3) SaberM2.Offset = Vector3.new(0, 0.24, -103.2/i)
      wait()
Saber.Transparency = 1
Saber2.Transparency = 1
PointLight.Enabled = false
end 
end
end
end)

The ignition part (when the laserblade comes out of the handle) works perfectly fine. However the sheathing of saber (when the laserblade part is put back into the handle) doesn't work and instead of smoothly backing into the handle, disappears to nowhere.

Could anyone tell me what's wrong with this script or what I need to change?

Thanks.

Answer this question