How do I tween my player smoothly up?

Hi, I need help making an alien UFO ship that abducts people. The code works kinda but the tweening is a bit glitchy here’s a video with my script and what is happening:

This is my script:

local Beam = script.Parent.Beam
local UFO = script.Parent.UFO
local debounce = false

Beam.Touched:Connect(function(hit)
	wait(0.5)
	local hum = hit.Parent:WaitForChild("Humanoid")
	if hum then
		if debounce == false then
			debounce = true
			local primary = hum.Parent:FindFirstChild("HumanoidRootPart")
			local Info = TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0)
			local goal = {}
			
			goal.CFrame = UFO.CFrame
			local TweenService = game:GetService("TweenService")
			local Tween = TweenService:Create(primary,Info,goal)
			Tween:Play()
			wait(5)
			script.Parent.Humanoid:TakeDamage(200)
			
		elseif debounce == true then
			print("Nothing")
		end
		
	end
	
end)

What's my problem?
1 Like

It could be the wait maybe that is dragging it down a bit try to bring it down a bit

2 Likes

I did it without the wait and it still did it. My intensions of the wait is to try and make sure that it isn’t looping the tween for a few seconds. Clearly that didn’t work. :confused:

2 Likes

Hmm I would maybe say distance maybe but idk I’m sorry I was unable to help today…

1 Like

It’s okay. I’m just thankful that someone at least saw my post. I’ll try to find a youtube channel on this topic. Thanks again!

2 Likes

No problem you have a good one.

1 Like

Anchor the HumanoidRootPart to stop that stuttering, its because physics and TweenService are colliding. TweenService involves no physics hence it goes against physics and it stutters. So, anchoring will prevent physics from acting on the player and you will be able to smoothly tween the position.

5 Likes

Or you could try BodyVelocity.

1 Like

Thank you so much Ani! I appreciate your idea because it worked. OctaViano I’ve tried body position and it kinda worked.

2 Likes

BodyPosition | Roblox Creator Documentation works well but it’s been replaced by AlignPosition | Roblox Creator Documentation.

Here’s a script I have in my Yeah, steampunk... - Roblox place for the vertical ascent (or descent, just change the b.Position to wherever you want the player to go) tubes.
The script is in a button on the ground.
I have the game as R6 so you may want to change character.Torso to character.HumanoidRootPart.

function onTouched(hit)
    local character = hit.Parent
    if character and character:findFirstChild("Humanoid") then
        local b = Instance.new("BodyPosition")
        b.position = Vector3.new(-615.414, -320.017, 337.296)
        b.maxForce = Vector3.new(3500, 9000, 3500)
		b.D = 500
		b.P = 1500
        b.Parent = character.Torso
		local g = Instance.new("BodyGyro")
        wait(3)
        b.Parent = nil
		g.Parent = nil
    end
end
script.Parent.Touched:connect(onTouched) 
1 Like

Thank you for that idea. I’ll try it next time when I make a similar project. :smiley:

1 Like

It works pretty smoothly, and if you change the D and P values you get a nice smooth acceleration and deceleration at the ends. You need to change the wait(3) time to whatever works best for your abduction ray.