Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

LocalScript not working?

Asked by 6 years ago
Edited 6 years ago

Hello, everyone!

I have just tried making an animation script for a tool. The sound plays, but the animation doesn't. Can someone please help? Thanks! :) PS. It is a local script, and the animation is made by Jazzyx3 (not on team create)

script.Parent.Equipped:connect(function(m)
    m.Button1Down:connect(function()
        local ani = Instance.new("Animation")
        ani.AnimationId = "http://www.roblox.com/Asset?ID=334721663"
        local anitrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(ani)
        anitrack:Play()
        wait(.05)
        script.Parent.Handle.Sound:Play()
    end)
end)
--
0
http://wiki.roblox.com/index.php?title=API:Class/AnimationTrack/AdjustWeight Your animation's weight is lower than the current animations running on the character. Probably LostPast 253 — 6y
0
is the animation made by you? is the game on team create? Elixcore 1337 — 6y
0
is it a localscript? Elixcore 1337 — 6y
0
did you set priority to action or movement? Elixcore 1337 — 6y
View all comments (4 more)
0
It's a local script, and the animation is made by Jazzyx3 (not on team create) DonutsIndeed 2 — 6y
0
you can't use other people's animations, you have to make your own Elixcore 1337 — 6y
0
roblox doesn't allow it Elixcore 1337 — 6y
0
Oh, I didn't know. DonutsIndeed 2 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You will need a RemoteEvent.

script.Parent.Equipped:Connect(function(mouse)
    mouse.Button1Down:Connect(function()
        local ani = Instance.new("Animation")
        ani.AnimationId = "rbxassetid://334721663"
        local anitrack = game:GetService("Players").LocalPlayer.Character.Humanoid:LoadAnimation(ani)
        anitrack:Play()
        wait(.05)
        script.Parent.PlaySound:FireServer(script.Parent.Handle.Sound)
    end)
end)

Server code:

script.Parent.PlaySound.OnServerEvent:Connect(function(plr, sound)  sound:Play()
end)
-- script inside tool, remote event inside tool

As others have said, animations must be self-made, but this will play sound.

On a side note, switch to :Connect()as :connect() is deprecated and should not be used in new work.

0
Thanks for telling me this! Altough, I already found a solution. But, thanks!! :D DonutsIndeed 2 — 6y
Ad

Answer this question