Why does the part move to the center of the baseplate?

Hello! So for some reason a part that is supposed to be at the position of another part moves to the center of the baseplate.

Where it is supposed to be:
devfor2

Where it moves:

I’ve also tried using cframe but that didn’t work aswell.

script:

while wait(0.8) do
	local ShotParticle = script.Parent.LaserChargePart.ShotParticles
	local LaserSphere = script.Parent -- Where the other part is supposed to be
	local Laser = script.Parent.Laser -- The part that moves to the center of the baseplate
	local Particle = script.Parent.LaserChargePart.Attachment.ParticleEmitter
	local ParticleLight = Particle.LightEmission
	
	
	local LaserSound = script.Parent.LaserChargePart.LaserSound
	local LaserChargeSound = script.Parent.LaserChargePart.LaserChargeSound
	
	
	local TS = game:GetService("TweenService")
	local Destination = Vector3.new(LaserSphere.Position, 11.078, LaserSphere.Position)
	local SizeDestination = Vector3.new(9.1, 0.4, 0.4)
	local TweenInfoPosition = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out,0,false)
	local TweenInfoSize = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out,0,false)
	local ChangeSize = TS:Create(Laser, TweenInfoSize, {Size = SizeDestination})
	local Bright = TS:Create(Particle,TweenInfo.new(1),{LightInfluence = 1000})
	local ChangePosition = TS:Create(Laser, TweenInfoPosition, {Position = Destination})
	local ChangeTransparancy = TS:Create(Laser, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out , 0, false),{Transparency = 1})
	
	
	
	local Position = LaserSphere.Position
	local Direction = -LaserSphere.CFrame.UpVector
	local rcParams = RaycastParams.new()
	rcParams.FilterDescendantsInstances = {LaserSphere,script.Parent.LaserChargePart}
	rcParams.FilterType = Enum.RaycastFilterType.Exclude

	local ray = workspace:Raycast(Position, Direction * 50)

	if ray then
		local Part = ray.Instance
		print(Part)
		local char = Part:FindFirstAncestorWhichIsA("Model")
		if char ~= nil then
			local h = char:findFirstChild("Humanoid")
			if h ~= nil then
				Particle.Enabled = true
				Bright:Play()
				LaserChargeSound:Play()
				wait(1)
				Particle.Enabled = false
				ShotParticle.Enabled = true
				ChangePosition:Play()
				ChangeSize:Play()
				LaserSound:Play()
				h:TakeDamage(30)
				wait(0.5)
				ShotParticle.Enabled = false
				wait(0.5)
				ChangeTransparancy:Play()
				wait(1)
				Laser.Transparency = 0
				Particle.LightInfluence = 0
				Laser.Position = Vector3.new(LaserSphere.Position, 18.519, LaserSphere.Position)
				Laser.Size = Vector3.new(1.8, 0.4, 0.4)
			end
		end
	end
end

Thanks in advance. :smile:

5 Likes

If you’re trying to change the actual CFrame value, then that’s not going to work.
You need to use the :PivotTo() method.

Here is an example:

local model = --The model.

model:PivotTo(
    CFrame.new(
        Vector3.new(0,0,0), --Position
        Vector3.new(0,0,0) --Orientation
    )
)
1 Like

It doesn’t work.
(30charcaterblalala)

1 Like

Try to hange name of all char to char1

while wait(0.8) do
	local ShotParticle = script.Parent.LaserChargePart.ShotParticles
	local LaserSphere = script.Parent -- Where the other part is supposed to be
	local Laser = script.Parent.Laser -- The part that moves to the center of the baseplate
	local Particle = script.Parent.LaserChargePart.Attachment.ParticleEmitter
	local ParticleLight = Particle.LightEmission
	
	
	local LaserSound = script.Parent.LaserChargePart.LaserSound
	local LaserChargeSound = script.Parent.LaserChargePart.LaserChargeSound
	
	
	local TS = game:GetService("TweenService")
	local Destination = Vector3.new(LaserSphere.Position, 11.078, LaserSphere.Position)
	local SizeDestination = Vector3.new(9.1, 0.4, 0.4)
	local TweenInfoPosition = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out,0,false)
	local TweenInfoSize = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out,0,false)
	local ChangeSize = TS:Create(Laser, TweenInfoSize, {Size = SizeDestination})
	local Bright = TS:Create(Particle,TweenInfo.new(1),{LightInfluence = 1000})
	local ChangePosition = TS:Create(Laser, TweenInfoPosition, {Position = Destination})
	local ChangeTransparancy = TS:Create(Laser, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out , 0, false),{Transparency = 1})
	
	
	
	local Position = LaserSphere.Position
	local Direction = -LaserSphere.CFrame.UpVector
	local rcParams = RaycastParams.new()
	rcParams.FilterDescendantsInstances = {LaserSphere,script.Parent.LaserChargePart}
	rcParams.FilterType = Enum.RaycastFilterType.Exclude

	local ray = workspace:Raycast(Position, Direction * 50)

	if ray then
		local Part = ray.Instance
		print(Part)
		local char1 = Part:FindFirstAncestorWhichIsA("Model")
		if char1 ~= nil then
			local h = char1:findFirstChild("Humanoid")
			if h ~= nil then
				Particle.Enabled = true
				Bright:Play()
				LaserChargeSound:Play()
				wait(1)
				Particle.Enabled = false
				ShotParticle.Enabled = true
				ChangePosition:Play()
				ChangeSize:Play()
				LaserSound:Play()
				h:TakeDamage(30)
				wait(0.5)
				ShotParticle.Enabled = false
				wait(0.5)
				ChangeTransparancy:Play()
				wait(1)
				Laser.Transparency = 0
				Particle.LightInfluence = 0
				Laser.Position = Vector3.new(LaserSphere.Position, 18.519, LaserSphere.Position)
				Laser.Size = Vector3.new(1.8, 0.4, 0.4)
			end
		end
	end
end
2 Likes

Nope, it doesn’t work.
(30charraaaa)

1 Like

That should help

Laser.Position = Vector3.new(LaserSphere.Position.X, 18.519, LaserSphere.Position.Z)

also u should get error from this line before changing it

3 Likes

It works! Thanks a lot.:smile:
(30charararra)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.