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

How would I store a TweenInfo into a module?

I decided putting TweenInfos into scripts looks really messy. So i decided to store them in a module script. After I did that, it print out this error(it was an error in a script btw):

00:20:54.378 - Unable to cast Array to TweenInfo

Module script:

local module = {}

module.radiationBurst = {
	TweenInfo.new(

		1.2, -- Length of tween
		Enum.EasingStyle.Sine, -- Easing style of tween
		Enum.EasingDirection.Out, -- Easing direction of tween
		0, -- repeat times of tween
		false, -- will tween repeat?
		0 -- delay between each tween, this will be useless if tween doesn't repeat


	)
}

return module

Script(error in line:32):

test.OnServerEvent:Connect(function(player)
	if player["AvailablePowers"]:FindFirstChild("test") then
		local character = player.Character or player.CharacterAdded:Wait()

		if character:FindFirstChild("Humanoid") then
			if character.Humanoid.Health > 0 then
				if character:FindFirstChild("HumanoidRootPart") then 
					
					local tweenService = game:GetService("TweenService")
					
					local radiation = Instance.new("Part")
					radiation.Size = Vector3.new(0.5,0.5,0.5)
					radiation.Anchored = true
					radiation.CanCollide = false
					radiation.CastShadow = false
					radiation.Material = Enum.Material.Neon
					radiation.Transparency = 0.3
					radiation.BrickColor = BrickColor.new("Lime green")

					radiation.Position = character["HumanoidRootPart"].Position

					radiation.Parent = workspace
					
					local tweeningInformation = tweenInfoModule.test
					
					local properties = {
						Size = Vector3.new(40,40,40);
						Color = BrickColor.new("Lime green");
						Transparency = 1
					}
					
					local expandTween = tweenService:Create(radiation, tweeningInformation, properties)
					
					expandTween:Play()
					
					
					local damage = math.random(49,55)
					
					local db = false
					
					local connection = radiation.Touched:Connect(function(hit)
						if hit and not db then
							db = true
							if hit.Parent:FindFirstChild("Humanoid") then
								hit.Parent["Humanoid"]:TakeDamage(damage)
							end
							wait(0.69)
							db = false
						end
					end)
					
					expandTween.Completed:Connect(function(playBackState)
						if playBackState == Enum.PlaybackState.Completed then
							connection:Disconnect()
							radiation:Destroy()
						end
					end)
				end
			end
		end
	else

		player:Kick("get outta here boi. no free powers here")
	end
end)

1 answer

✓ Accepted answer

Could you try replacing line 24 with this? Make sure to

 local tweeningInformation = require(PATH TO MODULESCRIPT).radiationBurst[1]

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