Scripting Support | Lazer Script Not Working

Hi! So I finished making a script for my tazer! (Thanks to the help of @blokav)

However, for some reason, my property changed script isnt working. Any ideas why?

Also, another problem. It takes around a second for the part to actually move. Any help would be appeciated!

local params = RaycastParams.new()

local range = 50

local lastpos = {X = tonumber(script.Parent.Position.X), Y = tonumber(script.Parent.Position.Y), Z = tonumber(script.Parent.Position.Z)}

local emitter = script.Parent
local beam = game.Workspace.Beam:Clone()
beam.Parent = workspace
beam.Name = "Beam_"..math.random(1,100)
script.Parent.Parent.beam.Value = beam

local tor = script.Parent.Parent.Parent.Torso

params.FilterDescendantsInstances = {emitter, beam}
params.FilterType = Enum.RaycastFilterType.Blacklist

tor.Changed:Connect(function(pr)
	if lastpos.X == tor.Position.X and lastpos.Y == tor.Position.Y and lastpos.Z == tor.Position.Z and pr == "Position" then
	else
		lastpos.X = tor.Position.X
		lastpos.Y = tor.Position.Y
		lastpos.Z = tor.Position.Z
		params.FilterDescendantsInstances = {emitter, beam}
		params.FilterType = Enum.RaycastFilterType.Blacklist

		local results = workspace:Raycast(emitter.Position, emitter.CFrame.LookVector * range, params)

		-- Beam
		local p = results and results.Position or (emitter.CFrame * CFrame.new(0, 0, -range)).Position
		beam.Size = Vector3.new(0.062, 0.062, (emitter.Position - p).Magnitude)
		beam.CFrame = CFrame.new((emitter.Position + p) / 2, p)
	end
end)