How could I make the click of a TextButton trigger an "animation" made through a script?
So, I'm working on a game with a friend. I came across a problem when I was making a teleporter thing. I was going to make a teleporter GUI in which if you clicked "Confirm", the teleporter itself would have an "animation", or in other words hover, spin and then come back down. Now, I have the script for the animation, which is:
01 | local model = script.Parent |
04 | local orig = script.Parent |
06 | local cf = orig:GetModelCFrame() |
09 | model:TranslateBy(Vector 3. new( 0 , 0.05 , 0 )) |
14 | local function ModelCFrame(Model,Frame) |
15 | local search,MidFrame,list = nil ,Model:GetModelCFrame(), { } |
17 | for n,o in pairs (a:GetChildren()) do |
18 | if (o:IsA( "BasePart" )) then |
25 | for n,o in pairs (list) do |
26 | o.CFrame = Frame*MidFrame:toObjectSpace(o.CFrame) |
31 | while (wait()) and i < 151 do |
33 | rotation = rotation+(speed/ 5 ) |
34 | if (rotation> 360 ) then rotation = 0 end |
35 | ModelCFrame(orig,cf*CFrame.Angles( 0 ,math.rad(rotation), 0 )) |
Now, this script works. I tested it and the animation works flawlessly. Great! Now, for the next part, I had to make this "animation" run after the "Confirm" button. So, I basically copied and pasted the above code into a script in the TextButton, put an OnClick function around it and connected the function to MouseButton1Down to the "Confirm" TextButton. It looked something like this:
4 | script.Parent.MouseButton 1 Down:connect(tele) |
Turns out that it didn't work. I tried and experimented with different changes. Nothing. Then, on a whim, I tried to use an if statement to do this (I had no idea what I was doing, so don't blame me if it's horrendously wrong D:) and also failed. It looked something like this:
1 | if script.Parent.MouseButton 1 Down then |
That failed as well. So, at this point, my friend and I are at a dead end. We have no idea what to do now, and we would really appreciate if someone could help us. And in case you want to see the end result of our game, look up the users, UsedMail (my friend) and/or IronSpider671(me) on ROBLOX. Thanks!