Animation is not playing. (Roblox) - animation

I am making a tool with an animation when clicked. However when I click nothing happens. I have tried 2 scripts and no errors come up but the animation doesn't play. I own the animation and other people said it worked and I don't know why it isn't for me. Here is my first script:
script.Parent.Activated:Connect(function()
local action = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.ANIMATE)
action:Play()
end)
And here is my second script:
local tool = script.Parent
local animation = tool.ANIMATE
tool.Activated:Connect(function()
local character = tool.Parent
local humanoid = character.Humanoid
local AnimationTrack = humanoid:LoadAnimation(animation)
AnimationTrack:Play()
end)
Any help appreciated!

It turns out I had an animation that was exactly the same as the one I needed for a different game that I forgot about that works in my script. I have no idea what happened with the newer ones but I can finally move on!

You should of searched in the Roblox Developer Documentation and you would of found that the Humanoid:LoadAnimation() function has been deprecated.
So you will need to use Humanoid.Animator:LoadAnimation().
script.Parent.Activated:Connect(function()
local action = script.Parent.Parent.Humanoid.Animator:LoadAnimation(script.Parent.ANIMATE)
action:Play()
end)
tool.Activated:Connect(function()
local character = tool.Parent
local humanoid = character.Humanoid
local AnimationTrack = humanoid.Animator:LoadAnimation(animation)
AnimationTrack:Play()
end)

Related

ive been trying to play an animation and the script is not working

`local button = game.StarterGui.ScreenGui.ImageButton
local AnimationController = script.Parent.AnimationController
local Animation = script.Animation
local animTrack = AnimationController:LoadAnimation(Animation)
local function PlayAnimation()
print("hi")
animTrack:Play()
end
button.MouseButton1Click:connect():Connect(PlayAnimation)`
, the print is not working so i assume its either the mousebutton1click is not working or the function is not connecting that is the first problem, the second is i have tried to start getting into animation and i could use some tips for animation of models that are moving cause of an event.
i tried changing some of the variables but that has not worked, i have tried writing it different, not working, tried chatGPT kinda helped, tried getting errors in the output with the print but that hasnt printed anything,i think cause of the connection to the gui button, that is all i can think of right now.
if you can help i would appreciate it.

I'm creating a little sound that plays when your mouse hovers over the button "White team" but nothing really happens. I'm using the MouseEnter event

I have been trying to create a sound every time your mouse leaves and enters this button. The code doesn't really work. I have tried this on a local script and a normal script:
script.Parent.MouseEnter:Connect(function()
local sound = script.Parent.Parent.hit
sound:Play()
end)
script.Parent.MouseEnter:Connect(function()
local soundTwo = script.Parent.Parent.hitS
soundTwo:Play()
end)
```[enter image description here][1]
[1]: https://i.stack.imgur.com/5niz4.png -- The explorer of the game (I used script and local script btw and none of them changed anything, but i do think local script would work better for a gui)
You can try adding the following lines at the top of your code.
if not sound.IsLoaded then sound.Loaded:Wait() end
if not soundTwo.IsLoaded then soundTwo.Loaded:Wait() end
Also, both of your functions are for MouseEnter. Try changing one to MouseLeave.

How can I have a button trigger a function to move the mouse cursor on a timer in C#/visual studio?

I'm building an automatic timer system as a fun silly project for some office chums. It's end user goal is to allow end users to be away from keyboard while still simulating activity to prevent timed applications from changing their statuses to away.
I have the front end of a windows form with two buttons. ON and OFF. When I press on, I want it to begin moving the mouse in 1 minute intervals for a moment. (or click maybe.) and when I select off it stops the action.
I've never really coded much before (I've done basic python stuff so I know what an if statement is, a function, how to declare a variable etc but I've never done anything with a GUI or in c# so this is all new.)
Lastly, I would want to save/export it as an exe for distribution for slackers I mean end users to run and use.
Thanks so much for the help!
Looks like someone is trying to hack their way out to keep their PC active when away from desk :D
//programmatically move the mouse example
PointConverter pc = new PointConverter();
Point pt = new Point();
pt = (Point)pc.ConvertFromString("0, 768");
Cursor.Position = pt;
Ref

Really Sporadic Unity Behavior? No Idea What is Causing it

So I have Unity 5 for Mac, I'm on OS X 10.11, and I'm using MonoDevelop. Over the past week or so this glitch, bug, whatever it is has been getting more and more annoying to the point where it is now. Currently I have 1 script running and when I play my project 2 things happen:
The script doesn't run! I have it outputting a ton of things and it doesn't output anything or do what it is supposed to. I've tried refreshing the assets and everything, but after the first run, nothing
There is an even stranger thing happening. I have a RawImage used to display the webcam and a plane far far away from this RawImage. I am making a custom material for this plane that only has white and red. Nonetheless, this plane also shows the webcam. There is no code or property connecting the 2 whatsoever.
These 2 events always happen together. Now I have to restart Unity almost every run to fix this. I'll run it once, maybe twice, sometimes even 3 times and it will work perfectly fine then the next time it will do these things. Sometimes after running it another few times it will switch back. Sometimes I'll run it 10 or 15 times and it doesn't go back and I have to restart Unity. Has anyone run into any form of this very strange bug / glitch before?
[EDIT] Here is the code that might be causing the problem. This code is called in the Start method:
IEnumerator TakePicAndGetBestColor() {
yield return new WaitForSeconds (0.5f);
print ("here");
if (webcamTexture.width > 100) {
print ("HERE");
initFrame = webcamTexture.GetPixels ();
currentFrame = initFrame;
print ("waiting again");
if (initFrame [0].r >= 0.999f || initFrame [0].g >= 0.999f || initFrame [0].b >= 0.999f) {
print ("waiting");
yield return new WaitForSeconds (0.5f);
}
sorterThread = new Thread (() => TrackPhone.SortColors(initFrame));
print ("started");
sorterThread.Start ();
}
}
It prints up to "here," but doesn't print "HERE."
Here are some screenshots:
My setup:
The canvas when it is played:
The plane (looking down) when it is played (it SHOULDN'T look like this):
What it should look like:
I have found no reason why the plane should have the webcam texture. Nothing in script or in Unity.

navigateToURL AS3 does nothing on Google Chrome only in my computer

I'm facing a strange behavior of flash Player, on my iMac, running OSX 10.9.2, and Chrome 33.0.1750.146 with Flash Player 12.0.0.70.
I use the following function, to open a page and post to it some jpg data. It worked bofore on my iMac. I can't remember when it stopped working. It is working well on Safari.
On other computers I have, including a Macbook, that runs same chrome and same flash player version, it is also working as expected. So, it sounds crazy.
private function SharePicture(evt:MouseEvent):void
{
var bit:BitmapData = new BitmapData(cena.width, cena.height);
var shiftOrigin:Matrix = new Matrix();
shiftOrigin.translate(-cena.x,-cena.y);
bit.draw(stage, shiftOrigin);
var jpgEncoder:JPGEncoder = new JPGEncoder(95);
var jpgStream:ByteArray = jpgEncoder.encode(bit);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest("some-page.php");
jpgURLRequest.requestHeaders.push(header);
//percentLoaded_txt.visible=true;
//percentLoaded_txt.text = processando;
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
navigateToURL(jpgURLRequest, "");
}
I already completely removed Google Chrome and reinstalled again, and no way, to make this code work.
You can try it by yourself, by accessing the following page:
http://www.scrapee.net/en/photo-wall-collage.htm - Just access it, and blick "Save Photo" button on the bottom.
Have anyone an ideal about what is causing this?
Thanks.
navigateToURL takes 2 parameters. The second one, in your case empty string, is the target, where this new window will be open. Possible values are: "_blank"(new window/tab), "_self" (same window/tab) and two others if you work with frames(not flash frames): "_top" and "_parent". For more info:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/package.html
If you don't pass anything as argument, default behavior is _blank, but in your case, you're passing a string, an empty string, and this could be the problem ...

Resources