Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't this script work? ANSWERED

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

✓ Accepted answer

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

1 comment

0

Wow, I feel so stupid thanks a lot PiggyJingles!

This discussion is preserved as it was. New answers, comments, and votes are closed.