I have Scripts That make it so the Sword appears on your back, and whenever you press F, You equip it in your Hand, And if you press F again, You Put it back (The Sword is a Model) But, The Animations Do not work! I need help.

Attack Script:

local Active = false
local HitNumber = 0 

game.ReplicatedStorage:WaitForChild("SwingEvent").OnServerEvent:Connect(function(player)
	Active = true
	local swinganim = Instance.new("Animation")
	swinganim.AnimationId = game:GetService("ReplicatedStorage"):WaitForChild("SwordConfiguration").Swing.Value
	local swinganimtrack = player.Character.Humanoid:LoadAnimation(swinganim)
	swinganimtrack:Play()
	player.Character.Sword.Sword.Swing:Play()
	delay(.360,function()
	local attachment0 = Instance.new("Attachment",player.Character.Sword.Sword)
	attachment0.Position = Vector3.new(0.087, -0, -0.501)
	local attachment1 = Instance.new("Attachment",player.Character.Sword.Sword)
	attachment1.Position = Vector3.new(0.078, -0, 2.272)
	local trail = player.Character.Sword.Sword.Trail
	trail.Attachment0 = attachment0
	trail.Attachment1 = attachment1
	delay(.490,function()
	attachment0:Destroy()
	attachment1:Destroy()
	swinganim:Destroy()
	swinganimtrack:Stop()
	end)
	end)
	player.Character.Sword.Sword.Touched:Connect(function(toucher)
		if toucher.Parent:FindFirstChild("Humanoid") ~= nil then
			if game:GetService("ReplicatedStorage").HitVals:FindFirstChild("HitVal"..toucher.Parent.Name) == nil then
				hitted = toucher.Parent
				print(toucher.Parent.Name)
				toucher.Parent.Humanoid:TakeDamage(game.ReplicatedStorage:WaitForChild("SwordConfiguration").Damage.Value)
				local hitter = Instance.new("Folder",game:GetService("ReplicatedStorage").HitVals)
				hitter.Name = "HitVal"..toucher.Parent.Name
			end
		end
	end)
	Active = false
	for i,v in pairs(game:GetService("ReplicatedStorage").HitVals:GetChildren()) do
		v:Destroy()
	end
end)

There is a folder in the Workspace Named: Settings, It has the Animations (Hold, Equip, Unequip, Damage, And Swing) All of them have KeyFrameSequences in them.

The sword is a Model, With Grouped parts in them named, Handle, Blade, And Back Weld. Also there is Qperfection weld Script in there.

There are also 2 Weld Scripts, Weld, and WeldAfter, I also have a Folder named "HitVal" I have a Animation dummy in for the animations.

Configuration Script:

script.Settings.Name = "SwordConfiguration"
script.Weld.Parent = game:GetService("ServerScriptService")
script.WeldAlter.Parent = game:GetService("ServerScriptService")
script.Attack.Parent = game:GetService("ServerScriptService")
script.EquipScript.Parent = game:GetService("StarterPack")
script.Sword.Parent = game:GetService("ReplicatedStorage")
script.EquipEvent.Parent = game:GetService("ReplicatedStorage")
script.SwingEvent.Parent = game:GetService("ReplicatedStorage")
script.HitVals.Parent = game:GetService("ReplicatedStorage")
script:WaitForChild("SwordConfiguration").Parent = game:GetService("ReplicatedStorage")
script.AnimationDummy:Destroy()
wait()
script:Destroy()

(Btw Everything is grouped under Configuration script)

3 comments

0

We need to see the script so we can actually help it. And also, maybe look at the output for any errors?

0

No errrors, I will edit the post

0

where do i start reading this lol