Hi, I wanted to make a Local Script that plays a sound each time a tool is equipped or unequipped, however, the Local Scripts seems to not recognize anymore children of parts.
Here’s some pictures (from top to bottom: the Explorer Tab, the Local Script, the Error):

Please someone help me fix this. Thank you.
Try putting:
local character = plr.Character or plr.CharacterAdded:Wait()
instead of just:
local character = plr.Character
Thanks, always used the other method and it worked everytime. Idk why it doesn’t work anymore.
Have you tried it many times and always gave error? If not, the error maybe have been caused just because the server-client communication was a little bit slower than usual.
That’s because is always recommended waiting for the thing to spawn instead of just getting it.
I mean:
local something = workspace:WaitForChild("something")
is more preferable than
local something = workspace.something
just because of that.
Nah the WaitForChild don’t work, already tried that.
The issue was because your script is in starter player scripts, meaning it runs when the player joins the game, not when the character spawns in. You’ve now modified your code to wait for the character to spawn, but you’re not accounting for respawns. A player script runs only once, when you join the game. That means when the character dies and respawns it will stop working.
You should either switch to using a starter character script, that will run each time the character spawns, or modify your player script to listen for localplayer.CharacterAdded to get the character each time they spawn.
Here’s an implementation of your mechanic, still a player script, using CharacterAdded to account for respawns and the character spawning late:
local plr = game.Players.LocalPlayer
plr.CharacterAdded:Connect(function(character)
character.ChildAdded:Connect(function(object)
if object:IsA("Tool") then
script.Equip:Play()
end
end)
character.ChildRemoved:Connect(function(object)
if object:IsA("Tool") then
script.Unequip:Play()
end
end)
end)