Set StarterPack tool Equipped as default. [Help]

Hey! I have quick question.

The script works if i make it with while loop instead of playeradded function but i don’t want make it loop. It hurts the animation.

So why it won’t work?

local character = game:GetService("Players").LocalPlayer.Character
local tool = script.Parent
local animation = tool:WaitForChild("Animation")
local animationTrack = character.Humanoid:LoadAnimation(animation)

local canRun = true
local debounceTime = 2 

game.Players.PlayerAdded:Connect(function(plr)
	if tool.Unequipped then
		character:FindFirstChild("Humanoid"):EquipTool(tool)
	end
end)
	
local Players = game:GetService('Players')

Players.PlayerAdded:Connect(function(plr)
     plr.CharacterAdded:Connect(function(char)
          local tool = char:WaitForChild('TOOL NAME')
          local humanoid = char:FindFirstChildOfClass("Humanoid")
          humanoid:EquipTool(tool)
     end)
end)

Must be a server script and should be placed in server script service.
You are probably using a localscript since you are trying to find LocalPlayer

  1. Equipping a tool on the client might cause weird behavior
  2. In your code there is no point for the entire playerAdded function because you never use the plr that it returns
  3. You are always equipping the tool for the exact same character that you defined on line 1

Infinite yield possible on ‘Workspace.iQeeDEVS:WaitForChild(“Tool”)’

local Players = game:GetService('Players')

Players.PlayerAdded:Connect(function(plr)
     plr.CharacterAdded:Connect(function(char)
          local tool = plr.Backpack:FindFirstChild("ToolName")  or char:FindFirstChild("ToolName")
          local humanoid = char:FindFirstChildOfClass("Humanoid")
          humanoid:EquipTool(tool)
     end)
end)```
1 Like

Thanks bro, should i put the animation script in server too or should it be stay in local?

Doesn’t matter because animations will replicate from client to server

1 Like

You should run character animations on the client.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.