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

Why if I put this script on a part, its not going straight up, but its glitching?

Why if I put this script on a part, its not going straight up, but its glitching and I cant stand on it while it's expanding up in the air. I want it to go smoothly up and not in glitchy parts up and down again. I have no idea what to change(I'm a beginner in scripting). I hope someone can help me!

this is the script:

part = game.Workspace.Part

part.Touched:Connect(function()
	for i = 0,600,0.1 do
		part.Size = Vector3.new(17,i,16)
		wait()
	end 
end)

1 comment

0

Ok so the reason being your character cant really stand on something that is moving that fast have having its size set. You would need to use the part TweenService which I don't know enough about. Heres the wiki page for it: https://developer.roblox.com/en-us/api-reference/class/TweenService

1 answer

✓ Accepted answer

Hi!

As MrCatDoggo said, you could use Tweenservice! I'll provide a basic example:

First of all, it's better off to use script.Parent if the script is inside a part, not game.Workspace.Part.

local part = script.Parent
local tweenservice = game:GetService("TweenService") -- Defines TweenService for later use.
local debounce = false

part.Touched:Connect(function()
-- We see that the part has been touched!
-- We could use Tweenservice now!
if debounce == false then -- Extra measures so tweenservice isn't laggy.
	debounce = true
	-- Let's create the tweenservice.
	tweenservice:Create(part, TweenInfo.new(1,Enum.EasingStyle.Linear, Enum.EasingDirection.In),{Size = Vector3.new(17,30,16)}):Play()
end
end)

Let me explain the tweenservice a bit better. part is the object we're modifing. The number (1) is the amount of time it takes.

Easingstyle is the way the movement will ease. Linear is normal. Easingdirection is the direction of easing.

Now, the size part is what we'll modify. The Y value you can replace with how high you want it to be.

1 comment

0

Oh, i forgot the down part. You can use the same tweenservice but change the Y. Don't forget the debounce.. btw.

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