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

`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.

Related

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.

Animation is not playing. (Roblox)

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)

How Do i Make The Button Dispear When I go to next screen

This is the code of the game I'm working on. I want to know how to make the button go away when I press it. I have already tried putting hide.button in a few places but don't know if they were the right spots. I'm just learning how to code. Please help me figure this out. I also tried looking it up but couldn't find the problem
https://i.stack.imgur.com/V9Gji.png
Here is a reference from p5 itself that shows how to hide items, you can make the button a function by:
let button = createButton(**button settings**);
button.hide();
I see you tried to put button.hide() , but most likely did not make "button" a function, therefore p5 did not know what "button" was.
Hope that helped! Happy coding!
EDIT: Before you put
button.hide();
Try putting it in an if statement as below:
let button = createButton(**button settings**);
if(button.mousePressed){
button.hide();
}
Then put that in your sketches setup function

React Native - Adding a new view seems to have a default fade in animation

Every time I render a new view it seems to have a default fade in animation where the opacity goes from 0 - 1 over about 200 milliseconds. Is there any way to turn this off so the view appears immediately?
Sample code that would trigger the default animation;
{(() => {
if (itemIsOpen) {
return (
<CardOverlay />
)
}
})()}
CardOverlay component fades in when I want it to immediately appear.
I've been struggling with the same thing for a while now, it's been driving me around the bend but I've finally found the cause of it. Not sure if it's the same thing that caused your problem (and not sure if it's still relevant for you) but I thought I'd share it incase someone runs into the same problem.
My issue was caused by Animated.spring() -- I was using it on a sub-component (a little button that makes an image appear on the page) but it seems that as soon as you add spring anywhere in your visual tree it affects everything. Even if you put it in componentDidMount on the inner component it still affects the page-load animation for me.
Time to learn a bit more about how the react Animated library works methinks!

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.

Resources