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:
local player = game:GetService("Players").LocalPlayer local character = player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local tool = script.Parent local animation = humanoid:LoadAnimation(tool.Animation) tool.Equipped:Connect(function() animation:Play() -- Play Animation when tool is equipped end) tool.Unequipped:Connect(function() -- Unequipped event animation:Stop() -- Stop Animation when tool is no longer equipped end)
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:
local player = game:GetService("Players").LocalPlayer local character = player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local tool = script.Parent local animation = humanoid:LoadAnimation(tool.Animation) tool.Equipped:connect(function() script.Parent.Disabled = false end) tool.Equipped:Connect(function() animation:Play() -- Play Animation when tool is equipped end) tool.Unequipped:Connect(function() -- Unequipped event animation:Stop() -- Stop Animation when tool is no longer equipped end)
It does not work, and Script Analysis shows no errors.
Working on what Tim said you will need to disable the script before it goes into lighting and the enable it when it comes out of lighting. You will need a separate script to enable it. But, first when you send it to lighting, create this new line before it (wherever you might be sending it to lighting):
-- script.Parent = game.Lighting -- script.Disabled = true
Then, for your enabling phase:
game.Players.PlayerAdded:Connect(function(plr) script.Parent:GetPropertyChangedSignal("Parent"):Connect(function(parent) if parent == plr.Character or plr.Backpack then script.Parent.Disabled = false end end end
NB - This is not a functional script, for script 2 it must be inside the script and for script 1 it must be in customised to your moving script,
Disable RequiresHandle value in the tool, if it doesn't have a handle.