Tween works fine until I put it in a function thing?

local tweenService = game:GetService("TweenService")

--creating floatTween
local floatTweenInfo = TweenInfo.new(
	1, -- Time
	Enum.EasingStyle.Quad, -- EasingStyle
	Enum.EasingDirection.InOut, -- EasingDirection
	-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
	true, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime
)

local floatGoal = {}
floatGoal.Position = script.Parent.Position + Vector3.new(0, .5, 0)

local floatTween = tweenService:Create(script.Parent, floatTweenInfo, floatGoal)


--creating rotationTween
local rotationTweenInfo = TweenInfo.new(
	5, -- Time
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
	false, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime
)

local rotationGoal = {}
rotationGoal.Orientation = script.Parent.Orientation + Vector3.new(0, 360, 0)

local rotationTween = tweenService:Create(script.Parent, rotationTweenInfo, rotationGoal)



--main script
script.Parent.Changed:Connect(function()
	if script.Parent.Parent == workspace then
		floatTween:Play()
		rotationTween:Play()
	end
end)

This works perfectly. It floats up and down, and rotates slowly, as it should.

local tweenService = game:GetService("TweenService")


--main script
script.Parent.Changed:Connect(function()
	if script.Parent.Parent == workspace then
		
		--creating floatTween
		local floatTweenInfo = TweenInfo.new(
			1, -- Time
			Enum.EasingStyle.Quad, -- EasingStyle
			Enum.EasingDirection.InOut, -- EasingDirection
			-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
			true, -- Reverses (tween will reverse once reaching it's goal)
			0 -- DelayTime
		)

		local floatGoal = {}
		floatGoal.Position = script.Parent.Position + Vector3.new(0, .5, 0)

		local floatTween = tweenService:Create(script.Parent, floatTweenInfo, floatGoal)
		
		
		floatTween:Play()
		
		
		--creating rotationTween
		local rotationTweenInfo = TweenInfo.new(
			5, -- Time
			Enum.EasingStyle.Linear, -- EasingStyle
			Enum.EasingDirection.Out, -- EasingDirection
			-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
			false, -- Reverses (tween will reverse once reaching it's goal)
			0 -- DelayTime
		)

		local rotationGoal = {}
		rotationGoal.Orientation = script.Parent.Orientation + Vector3.new(0, 360, 0)

		local rotationTween = tweenService:Create(script.Parent, rotationTweenInfo, rotationGoal)
		
		
		rotationTween:Play()
	end
end)

But, suddenly, when I make NO CHANGES except put it in this function, it decides to stop working. But not completely stop working. Instead, it still (seems, at least) to rotate fine, but instead of floating up and down, it ever so slowly creeps upwards forever.

Why???
(This is in a server script, inside the object I am tweening)

I have a sneaking suspicion that the function you’ve set up will set itself off because of the event your using, but try to put a print inside of the function and show us what console looks like.

What do you mean set itself off?

If I remember correctly the .Changed event goes off in response to any property changing, which would include position and orientation. That means your function will start, then the tween will cause the function to go off again, which will cause the function to go off again (repeat forever).
The reason behind it’s behavior is that Tweens will override another tween working with the same property, so the floattween can only begin to move it upwards before it’s cancelled out by another floattween doing the same, and since back is slow at first unlike linear which is constant the upwards movement is slow while the rotation is normal.

So what you’re saying is that the property constantly changing (due to the tweening) will constantly set off the .Changed event, and since it will always be in workspace it will constantly fire the tween, almost “resetting” it? But, if that’s the case, why isn’t the rotation being affected…?

I explained that in the last part of my post, but let me elaborate further.
Your position tween is using Quad easingstyle
your rotation tween is using Linear easingstyle
they are both being reset constantly, but the position uses a sort of exponential movement, meaning it’s slow at first and fast at the end, while the rotation uses a constant movement, never changing in speed.
That means that even though the rotation is being reset, it’s speed never changes, but when the position is reset it’s brought back to that slow starting speed.