So, a while ago i asked the same question but didn't get any answers and it was absolutely forgotten, now i will try again. What i'm trying to do is so that when i equip a tool, it changes the default animations of the player, i managed to make it change the default animations, though the issue is that they won't play immediately, instead it waits for me to move.
Tool's localscript:
local tool = script.Parent
tool.Equipped:Connect(function()
char = tool.Parent
local faketool = tool.Parent:FindFirstChild("FakeTool")
if faketool then
faketool:Destroy()
end
anim = tool.Parent:WaitForChild("Animate")
anim.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=2998472932"
anim.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=2997967055"
anim.run.RunAnim.AnimationId = "http://www.roblox.com/asset/?id=2997986131"
end)
tool.Unequipped:Connect(function()
anim.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=2510196951"
anim.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=2510202577"
anim.run.RunAnim.AnimationId = "http://www.roblox.com/asset/?id=2510198475"
local fake = script.Parent.FakeTool:Clone()
fake.Parent = char
local weld = Instance.new("Weld")
weld.Name = fake.Name
weld.Parent = fake.Blade
weld.Part0 = fake.Blade
weld.Part1 = char:FindFirstChild("UpperTorso")
fake.Blade.Transparency = 0
fake.Handle.Transparency = 0
weld.C0 = CFrame.new(0.7,0,0.7)
weld.C0 = weld.C0 * CFrame.fromEulerAnglesXYZ(90,4.7,1)
end)
Localscript inside of the character(I need this because i removed the backpack gui from the game) :
wait()
local uis = game:GetService("UserInputService")
local tool = game.ReplicatedStorage:FindFirstChild("Tool")
local name = script.Parent.Name
local find = game.Players:WaitForChild(name).Backpack
local char = script.Parent
if find then
local backpacktool = find:FindFirstChild("Tool")
if backpacktool then
print("YOU HAVE THE TOOL")
end
if not backpacktool then
local toolcopy = tool:Clone()
toolcopy.Parent = find
local faketool = tool:FindFirstChild("FakeTool")
local fake = faketool:Clone()
fake.Parent = char
local weld = Instance.new("Weld")
weld.Name = fake.Name
weld.Parent = fake.Blade
weld.Part0 = fake.Blade
weld.Part1 = char:FindFirstChild("UpperTorso")
fake.Blade.Transparency = 0
fake.Handle.Transparency = 0
weld.C0 = CFrame.new(0.7,0,0.7)
weld.C0 = weld.C0 * CFrame.fromEulerAnglesXYZ(90,4.7,1)
print("TAKE THE TOOL")
end
end
local toolinbackpack = find:FindFirstChild("Tool")
local equip = false
uis.InputBegan:Connect(function(input, gameprocess)
if input.KeyCode == Enum.KeyCode.E then
local human = script.Parent:WaitForChild("Humanoid")
if not equip then
local equipplay = human:LoadAnimation(tool.equip)
equipplay:Play()
wait(0.01)
human:EquipTool(toolinbackpack)
equip = true
return end
if equip then
local unequipplay = human:LoadAnimation(tool.unequip)
unequipplay:Play()
wait(0.35)
human:UnequipTools(toolinbackpack)
equip = false
return end
end
end)
Note out that i did some changes to the Animate script as well. Animate script changes:
Tool animations were removed (toollunge, toolnone, toolslash)
Animations are picking up the animations through the animation instances not through the website as its scripted. Example:
idle = { { id = script.idle.Animation1, weight = 9 }
I tried:
- Forcing animation after and before the changes
- Stopping and restarting all playing animations
Nothing worked so far.
