LocalScript animation tool doesn't work when copied from Lighting. How can I fix this?
Asked by
4 years ago Edited 4 years ago
To clarify, I'm a massive noob. It's likely I'm making a mistake that shows that.
The tool is intended to play a simple animation holding a simple object. It works fine when placed in StarterPack.
However, I do not want all players to have access to it. I want it to be accessible only by using Kohl's admin, which copies tools from Lighting.
The tool, when copied from Lighting (or dragged into the player backpack in Explorer), does not function. It just holds the object as if there were no scripts.
The following is the contents of the LocalScript. It is not my code, but perhaps it's relevant:
01 | local player = game:GetService( "Players" ).LocalPlayer |
02 | local character = player.CharacterAdded:Wait() |
03 | local humanoid = character:WaitForChild( "Humanoid" ) |
05 | local tool = script.Parent |
07 | local animation = humanoid:LoadAnimation(tool.Animation) |
09 | tool.Equipped:Connect( function () |
13 | tool.Unequipped:Connect( function () |
FilteringEnabled did not appear to cause any change in behavior.
I appreciate all ideas, thanks!
Edit1:
I attempted to reenable the script once equipped, having disabled it in Lighting. Here is the amended code:
01 | local player = game:GetService( "Players" ).LocalPlayer |
02 | local character = player.CharacterAdded:Wait() |
03 | local humanoid = character:WaitForChild( "Humanoid" ) |
05 | local tool = script.Parent |
07 | local animation = humanoid:LoadAnimation(tool.Animation) |
09 | tool.Equipped:connect( function () |
10 | script.Parent.Disabled = false |
13 | tool.Equipped:Connect( function () |
17 | tool.Unequipped:Connect( function () |
It does not work, and Script Analysis shows no errors.