|
| 07 Mar 2015 03:29 PM |
I tried to make a script that play an animation when you equipped a gun:
tool = script.Parent
function onActivated() --when clicked end
function onEquipped() -- when equipped local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=224251550" local Humanoid = script.Parent.Parent.Humanoid local animTrack = Humanoid:LoadAnimation(animation) animTrack:Play() wait() end
tool.Activated:connect(onActivated) tool.Equipped:connect(onEquipped)
It works when I un-equip the tool. Try it for yourself on studio!
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 08 Mar 2015 01:55 AM |
I'ma just throw something out here: It seems you've only got the one animation.
... Yeah. |
|
|
| Report Abuse |
|
|
|
| 08 Mar 2015 03:04 AM |
| I need it to play that animation while he holds the gun... FOREVER! |
|
|
| Report Abuse |
|
|
|
| 08 Mar 2015 03:07 AM |
Your code is fine
But you probably don't have a handle in your tool.
Insert a part in tool and name it "Handle"
And set up your code so the parents are to the tool. |
|
|
| Report Abuse |
|
|
|
| 08 Mar 2015 03:34 AM |
I do have a Handle, where does the script go?
BTW I made a new script
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
tool.Activated:connect(function() --when clicked handle.FireSound.Volume = 15 handle.FireSound:Play() end)
tool.Equipped:connect(function(mouse) -- when equipped equipped = true if mouse then mouse.Icon = "rbxasset://textures\\GunCursor.png" end local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=224251550" local Humanoid = script.Parent.Parent.Humanoid local animTrack = Humanoid:LoadAnimation(animation) animTrack:Play() wait() end)
|
|
|
| Report Abuse |
|
|
|
| 08 Mar 2015 03:36 AM |
| BTW the animation is 0.20 seconds long. How do I play it for longer? |
|
|
| Report Abuse |
|
|
|
| 08 Mar 2015 03:56 AM |
You can have the script inside the tool or in the handle. It shouldn't matter.
But to make the animation longer you simply have to either make the animation longer or set it to looped.
There is a tick box to loop an animation when you're creating it. |
|
|
| Report Abuse |
|
|
|
| 08 Mar 2015 04:02 AM |
so...
animation.Looped = true? |
|
|
| Report Abuse |
|
|
|
| 08 Mar 2015 04:03 AM |
| No it's not a part of the script, I wish. But when you are creating the animation you have to set it as looped. You can't do it after it's been made. |
|
|
| Report Abuse |
|
|
| |
|
KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
|
| 08 Mar 2015 02:30 PM |
Animation.Parent = something? heard of .Parent??? and about the Speed... AnimTrack:AdjustSpeed(1.5) --will Play 1.5 Times Faster than it should... |
|
|
| Report Abuse |
|
|
|
| 09 Mar 2015 12:31 PM |
| Nope, only works when I un-equip the gun. |
|
|
| Report Abuse |
|
|
Roblok1
|
  |
| Joined: 27 Jul 2011 |
| Total Posts: 2019 |
|
|
| 09 Mar 2015 12:35 PM |
| in order for animations to work, u need to put the code in a local script. |
|
|
| Report Abuse |
|
|
KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
|
| 09 Mar 2015 01:06 PM |
| ya mean after u Unequip it or JUST wen u Unequip it? |
|
|
| Report Abuse |
|
|
|
| 09 Mar 2015 01:34 PM |
Dude since you're having problems with ROBLOX animations you should use CFrame. Because these ROBLOX animations are annoying so CFrame animations are much more better trust me.
p = game.Players.LocalPlayer c = p.Character
bd = c.HumanoidRootPart.RootJoint -- Torso's CFrame a1 = c.Torso:FindFirstChild("Left Shoulder") -- Left Arm's CFrame a2 = c.Torso:FindFirstChild("Right Shoulder") -- Right Arm's CFrame l1 = c.Torso:FindFirstChild("Left Hip") -- Left Leg's CFrame l2 = c.Torso:FindFirstChild("Right Hip") -- Right Leg's CFrame
for i = 1,5 do wait() -- CFrame Animation a2.C0 = a2.C0 * CFrame.Angles(0,0,0.2) end for i = 1,5 do wait() -- CFrame Animation a2.C0 = a2.C0 * CFrame.Angles(0,0.2,0) end
(rotation,rotate left/right,up/down) |
|
|
| Report Abuse |
|
|
|
| 09 Mar 2015 01:44 PM |
just loop the animation
if the loop interrupts ur script use a coroutine |
|
|
| Report Abuse |
|
|