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

How to create an animation playing script?

So I've made an animation for a ceiling fan that I've finished, and through the animation editor, it runs perfectly fine, but what I'm having trouble with is figuring out is how to make it run in-game automatically when the place starts. What I was hoping I could make is almost like a "while true do" kind of scrip that makes the animation run and loop for as long as the place is open, but I am not familiar with anything related to animations other than making them.

If anyone can help me, it would be nice if they can also tell me where to put the script in the model and what essential parts are required in the model as well.

1 answer

Explaining here would be really long, so here's a wiki reference.

From number 2 onwards.

http://wiki.roblox.com/index.php?title=Animations#Using_Animation_in_Games

If you need an alternative solution:

There is also another way of making a "fan-animation" that is just simply rotating it.

--This is not my script.

--This script was made by CrazyMan32, I took it from it's "Public Scripts" set.

function rotateMod(mod,center,rotation)
	local parts ={}
	local function scan(parent)
		for _,obj in pairs(parent:GetChildren()) do
			if (obj:IsA("BasePart")) then
				table.insert(parts,obj)
			end
			scan(obj)
		end
	end
	scan(mod)
	for _,part in pairs(parts) do
		part.CFrame = (center*rotation*(center:inverse()*part.CFrame))	-- Credit to oysi93 for this equation thing
	end
end

--[[

rotateMod(mod Model, center CFrame, rotation CFrame)

Example:
	rotateMod(model, model:GetModelCFrame(), CFrame.Angles(0,math.rad(2),0)


Example:

local mod = game.Workspace.MODEL
local step = 1
for i = 0,360,step do
	rotateMod(mod,mod:GetModelCFrame(),CFrame.Angles(0,math.rad(step),0))
	wait()
end

]]

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