Trying to make a Lightsaber

  1. What do you want to achieve?
  • I want to achieve a effect of the Lightsaber turning on.
  • The Sounds and Size stuff is working.
  • TweenService just doesn’t like to move stuff in script.
  1. What is the issue?
  1. What solutions have you tried so far?
  • a lot of experimenting and surfing the webs and forum
  • And I am Becomming mentally Unstable…
tool = script.Parent
handle = tool:WaitForChild("Handle")

local TweenService = game:GetService("TweenService")

local lightSaberBeam0 = script.Parent.LightSaberModel.PlasmaBeam.Union0
local lightSaberBeam1 = script.Parent.LightSaberModel.PlasmaBeam.Union1

local lightSaberBeamSize0 = {}
local lightSaberBeamSize1 = {}
lightSaberBeamSize0.Size = Vector3.new(3.586, 0.134, 0.134)
lightSaberBeamSize1.Size = Vector3.new(3.604, 0.11, 0.11)

local lightSaberBeamPosition0 = {}
local lightSaberBeamPosition1 = {}
lightSaberBeamPosition0.Position = lightSaberBeam0.Position + Vector3.new(1, 0, 0)
lightSaberBeamPosition1.Position = lightSaberBeam1.Position + Vector3.new(1, 0, 0)

local TweenInfo0 = TweenInfo.new(2)
local Tween0 = TweenService:Create(lightSaberBeam0, TweenInfo0, lightSaberBeamSize0)
local TweenInfo1 = TweenInfo.new(2)
local Tween1 = TweenService:Create(lightSaberBeam1, TweenInfo1, lightSaberBeamSize1)
local TweenInfo2 = TweenInfo.new(3)
local Tween2 = TweenService:Create(lightSaberBeam0, TweenInfo2, lightSaberBeamPosition0)
local TweenInfo3 = TweenInfo.new(3)
local Tween3 = TweenService:Create(lightSaberBeam1, TweenInfo3, lightSaberBeamPosition1)

tool.Equipped:Connect(function()

	lightSaberBeam0.Size = Vector3.new(0, 0.134, 0.134)
	lightSaberBeam1.Size = Vector3.new(0, 0.11, 0.11)

	lightSaberBeam0.Position = lightSaberBeam0.Position + Vector3.new(-1, 0, 0)
	lightSaberBeam1.Position = lightSaberBeam1.Position + Vector3.new(-1, 0, 0)

	print("the tool is Equiped")

	task.wait(0.2)
	local sound0 = workspace.Sounds.LightSaberTurnOn
	Tween0:Play()
	Tween1:Play()
	Tween2:Play()
	Tween3:Play()
	sound0:Play()
	Tween0.Completed:Wait()
	
end)

You’re only tweening the size of it, it shrinks/grows from the origin position of the part, so it behaves how you’ve told it to. You would want to have the beam begin very small along the axis it expands on, positioned at the hilt of the saber. Tween the Position to move from the hilt to half the distance to the end of the blade, and tween the Size only on the one axis from ~0 to its full length. It’ll make it grow as fast as it is moving so it will look like a continuous beam growing from the hilt.

thats what the position stuff is for but it doesn’t move anything

Right, because your logic behind moving the parts from [...].Position + Vector3.new(-1, 0, 0) to [...].Position + Vector3.new(1, 0, 0) isn’t a proper reference to and from the hilt of the saber, you’re just adding a world vector to its old position. I wrote a quick example in studio to explain what I mean about the position:

local TweenService = game:GetService("TweenService")
local hilt = script.Parent.hilt
local blade = script.Parent.blade

local goal = {}
goal.Position = blade.Position
goal.Size = blade.Size
--Before the animation plays, I grab its current positions.
blade.CFrame = hilt.CFrame
blade.Size = blade.Size * Vector3.new(1,0,1)
--Now I flatten the blade and place it inside of the hilt.
TweenService:Create(blade, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true), goal):Play()
--Now I tween the blade from the hilt(off) position to its original(on) position.
--For demo purposes it's set to infinitely loop back and forth.

This is just two parts that I roughly threw together to look like a sword in a model with a LocalScript. The blade is tall and above the hilt on the y-axis

I think I get the logic behind it
and I’ll give it a try later

  • but first I got some IRL stuff to do sadly

I did a Rough Implementation of the stuff you wrote down…

  • First I Copy Pasted the code twice in studio and I filled in the stuff I needed
  • Then I Pushed the script to Commit…
  • And when I started the game to test… This starts happening
  • Reworked Lightsaber Script - YouTube

I am so confused right now… when I read it I thought it made sense
Atleast it’s a lot cleaner

local tool = script.Parent
local handle = tool:WaitForChild("Handle")

local TweenService = game:GetService("TweenService")

local lightSaberBeam0 = script.Parent.LightSaberModel.PlasmaBeam.Union0
local lightSaberBeam1 = script.Parent.LightSaberModel.PlasmaBeam.Union1
local hilt = script.Parent.LightSaberModel.Hilt.Hilt

tool.Equipped:Connect(function()

	print("the tool is Equiped")

	task.wait(0.2)

	local sound0 = workspace.Sounds.LightSaberTurnOn
	local goal0 = {}
	local goal1 = {}

	sound0:Play()

	goal0.Position = lightSaberBeam0.Position
	goal1.Position = lightSaberBeam1.Position
	goal0.Size = lightSaberBeam0.Size
	goal1.Size = lightSaberBeam1.Size

	lightSaberBeam0.CFrame = hilt.CFrame
	lightSaberBeam1.CFrame = hilt.CFrame
	lightSaberBeam0.Size = lightSaberBeam0.Size * Vector3.new(1,0,1)
	lightSaberBeam1.Size = lightSaberBeam1.Size * Vector3.new(1,0,1)

	TweenService:Create(lightSaberBeam0, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true), goal0):Play()
	TweenService:Create(lightSaberBeam1, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true), goal1):Play()

end)

Help will be Appreciated.

  • Kind Regards
  • LikeMyDeathNote.