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? ANSWERED

Asked by
Avectus 120
9 years ago

I'm trying to make a lightsaber and I have put the code below inside a LocalScript which is in the Lightsaber (Tool).

-- Created by Avectus

-- Saber Variables
local Handle = script.Parent.Handle
local Saber = script.Parent.Saber -- Saber PART
local SaberM = script.Parent.Saber.SaberM -- Saber MESH


-- Player Variables
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()


-- Ignition Key
Mouse.KeyDown:connect(function(k) 
k = k:lower() 
if k == "q" then 
Saber.Transparency = 0


for i = 1, 9 do

    SaberM.Scale = Vector3.new(0.25, 0.1, 0.25) 
    wait()
    SaberM.Scale = Vector3.new(0.25, 0.2, 0.25) 
    wait()
    SaberM.Scale = Vector3.new(0.25, 0.3, 0.25) 
    wait()
    SaberM.Scale = Vector3.new(0.25, 0.4, 0.25) 
    wait()
    SaberM.Scale = Vector3.new(0.25, 0.5, 0.25) 
    wait()
    SaberM.Scale = Vector3.new(0.25, 0.6, 0.25) 
    wait()
    SaberM.Scale = Vector3.new(0.25, 0.7, 0.25) 
    wait()
    SaberM.Scale = Vector3.new(0.25, 0.8, 0.25) 
    wait()
    SaberM.Scale = Vector3.new(0.25, 0.9, 0.25) 

end
end 
end)

For some reason I get this as the outcome: https://youtu.be/i0mrB94_6ts

Could someone please tell me what I've done wrong or what I need to add in?

Thanks.

1 answer

Log in to vote
1
Answered by 9 years ago

You are repeating what you want to do 9 times rather than once:

for i = 1, 9 do
      SaberM.Scale = Vector3.new(0.25, i/10, 0.25) 
      wait()
end
0
Wow, I feel so stupid thanks a lot PiggyJingles! Avectus 120 — 9y
Ad

Answer this question