I want this to run when it is clicked rather then when you enter a game.
local increment = .05
function RunAnimation(p)
local p = p or script.Parent
local rightframe = p.CFrame + p.CFrame:vectorToWorldSpace( Vector3.new(1,0,0) * p.Size.X/2 )
for i = 0, math.pi/2, .05 do
wait()
local newframe = rightframe * (CFrame.Angles(0, -i, 0) *
CFrame.new(p.Size.X/-2,0,0))
p.CFrame = newframe
end
end
RunAnimation()

3 comments
Be more specific and what exactly are you trying to do?
I am trying to make the function run when it is click. I have tried brick.ClickDetector.MouseClick:connect(RunAnimation) with brick already defined. It doesn't work.
You can't declare a variable with a conditional operator for local p