of     1   

PleasantKillerman
#141415925Thursday, July 24, 2014 8:12 PM GMT

I want something that can run 3 different animations called from a function ( here's the 3 functions: FFf(),FFr() and FFl() ). I want that one of them is randomly chosen by a math.random. How can I do this? Thank you in advance! (: local mouse = game.Players.LocalPlayer:GetMouse() function run(key) if key == "f" then player = game.Players.LocalPlayer FFf() -- one of my 3 functions end end mouse.KeyDown:connect(run)
cntkillme
#141416114Thursday, July 24, 2014 8:14 PM GMT

local functions = {"FFf", "FFr", "FFI"}; local env = getfenv(); function run(key) if key == "f" then local func = functions[#functions]; env[func](); end end mouse.KeyDown:connect(run) Make sure your functions are not local
PleasantKillerman
#141416760Thursday, July 24, 2014 8:20 PM GMT

What do you mean by local? And it says it doesn't work. this line -- env[func]();
cntkillme
#141416893Thursday, July 24, 2014 8:21 PM GMT

Make sure the function exists (and that I spelled them right in the table) I think I made a mistake and put I instead of l on the 3rd value of the table
PleasantKillerman
#141417508Thursday, July 24, 2014 8:27 PM GMT

I already corrected your "I" mistake but it steal not working. And the three functions exist. I can give you an example of them if it can helps you. They are both same except for the line where I comment. function FFl() if debounce==true then return end debounce=true Char = player.Character Human = Char.Humanoid Torso = Char.Torso CF = Torso.CFrame Human.PlatformStand = false Human.Sit = true VelUp = Instance.new("BodyVelocity") VelUp.velocity = Vector3.new(0,-5000,0)+Torso.CFrame.lookVector*15 VelUp.P = VelUp.P*-1000 VelUp.maxForce = Vector3.new(10000,10000,10000)*999 VelUp.Parent = Torso coroutine.resume(coroutine.create(Down),VelUp) Gyro = Instance.new("BodyGyro") Gyro.P = Gyro.P*10 Gyro.maxTorque = Vector3.new(100000,100000,100000)*999 Gyro.cframe = CF Gyro.Parent = Torso for i=1, 14 do Gyro.cframe = Gyro.cframe*CFrame.fromEulerAnglesXYZ(math.pi/-9,math.pi/-18,0) --here wait() end Gyro.cframe = CF wait() Gyro:remove() Human.PlatformStand = false Human.Sit = false _restoreproperties() debounce=false end
cntkillme
#141417604Thursday, July 24, 2014 8:28 PM GMT

What is the output?
PleasantKillerman
#141417849Thursday, July 24, 2014 8:30 PM GMT

This one: env[func](); 16:18:49.068 - Script 'Players.Player1.PlayerGui.F to Flip', Line 153
cntkillme
#141417979Thursday, July 24, 2014 8:31 PM GMT

I need the actual output, not the trace. Does it say " attempt to call global '___' (a nil value)" or?
PleasantKillerman
#141418386Thursday, July 24, 2014 8:35 PM GMT

Oh. my bad. Yes it said: 16:18:49.065 - Players.Player1.PlayerGui.F to Flip:115: attempt to index global 'player' (a nil value)
cntkillme
#141418495Thursday, July 24, 2014 8:36 PM GMT

Oh, I antecedently removed the 'player = game.Players.LocalPlayer '
cntkillme
#141418557Thursday, July 24, 2014 8:36 PM GMT

Accidentally* Stupid auto-correct.
PleasantKillerman
#141418593Thursday, July 24, 2014 8:37 PM GMT

Oh that's true lol. Well I'll try with it.
PleasantKillerman
#141419278Thursday, July 24, 2014 8:43 PM GMT

It worked but it's doing the same move everytimes... Except if I'm very unlucky, it's doing the same function. It's doing FFl everytimes...
PleasantKillerman
#141420302Thursday, July 24, 2014 8:52 PM GMT

bump
cntkillme
#141420314Thursday, July 24, 2014 8:52 PM GMT

That's math.random's fault. Add this to the top line: math.randomseed(tick());math.random();math.random();
PleasantKillerman
#141420877Thursday, July 24, 2014 8:57 PM GMT

It still doesn't working...
lampwnage121
#141421226Thursday, July 24, 2014 9:00 PM GMT

"local func = functions[#functions];" You forgot to use math.random
cntkillme
#141421468Thursday, July 24, 2014 9:02 PM GMT

wow I dumb, yeah: lacol func = functions[math.random(#functions)]
PleasantKillerman
#141422013Thursday, July 24, 2014 9:06 PM GMT

Yeah, I knew that there was something missing... XD It finally worked1 Thank you guys! I hope you have a good day!
Benocular
#141425493Thursday, July 24, 2014 9:35 PM GMT

:)

    of     1