I believe this should work but for some reason it doesn’t print the second “hi” meaning that it isn’t being detected when it’s equipped or unequipped, can anyone help me?
Code:
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local idle1 = “http://www.roblox.com/asset/?id=180435571”
local idle2 = “http://www.roblox.com/asset/?id=180435792”
local walk1 = “http://www.roblox.com/asset/?id=180426354”
local animate = char:FindFirstChild(“Animate”)
local idle = animate:FindFirstChild(“idle”)
local walk = animate:FindFirstChild(“walk”)
local tool = game.StarterPack.Tool
print(“Hi”)
game.StarterPack.Tool.Equipped:Connect(function()
print(“hi”)
idle:FindFirstChild(“Animation1”).AnimationId = game.ReplicatedStorage.BookIdle.AnimationId
idle:FindFirstChild(“Animation2”).AnimationId = game.ReplicatedStorage.BookIdle.AnimationId
walk:FindFirstChild(“WalkAnim”).AnimationId = game.ReplicatedStorage.BookWalk.AnimationId
game.SoundService[“Gasps Male Deep Breaths Fast Pants Frightene (SFX)”].Looped = true
game.SoundService[“Gasps Male Deep Breaths Fast Pants Frightene (SFX)”]:Play()
end)
game.StarterPack.Tool.Unequipped:Connect(function()
game.SoundService[“Gasps Male Deep Breaths Fast Pants Frightene (SFX)”]:Stop()
idle:FindFirstChild(“Animation1”).AnimationId = idle1
idle:FindFirstChild(“Animation2”).AnimationId = idle2
walk:FindFirstChild(“WalkAnim”).AnimationId = walk1
end)
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local idle1 = “http://www.roblox.com/asset/?id=180435571 2”
local idle2 = “http://www.roblox.com/asset/?id=180435792 1”
local walk1 = “http://www.roblox.com/asset/?id=180426354 2”
local animate = char:FindFirstChild(“Animate”)
local idle = animate:FindFirstChild(“idle”)
local walk = animate:FindFirstChild(“walk”)
local tool = game.StarterPack.Tool
print(“Hi”)
game.StarterPack.Tool.Equipped:Connect(function()
print(“hi”)
idle:FindFirstChild(“Animation1”).AnimationId = game.ReplicatedStorage.BookIdle.AnimationId
idle:FindFirstChild(“Animation2”).AnimationId = game.ReplicatedStorage.BookIdle.AnimationId
walk:FindFirstChild(“WalkAnim”).AnimationId = game.ReplicatedStorage.BookWalk.AnimationId
game.SoundService[“Gasps Male Deep Breaths Fast Pants Frightene (SFX)”].Looped = true
game.SoundService[“Gasps Male Deep Breaths Fast Pants Frightene (SFX)”]:Play()
end)
game.StarterPack.Tool.Unequipped:Connect(function()
game.SoundService[“Gasps Male Deep Breaths Fast Pants Frightene (SFX)”]:Stop()
idle:FindFirstChild(“Animation1”).AnimationId = idle1
idle:FindFirstChild(“Animation2”).AnimationId = idle2
walk:FindFirstChild(“WalkAnim”).AnimationId = walk1
end)
That code inside the function has the same indentation level as the code outside, from what I can tell. Make sure any code for inside the function is indented.
Therefore, you could let each client handle their own backpack.
In StarterPlayerScripts, insert a LocalScript:
local player = game.Players.LocalPlayer
local backpack = player:WaitForChild("Backpack")
local tool = backpack:WaitForChild("Tool")
tool.Equipped:Connect(function()
print("Equipped tool")
end)