Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script Will Play Animation but animation does not do the right thing...?

GIF: https://gyazo.com/aec7f0f8ec266b213ff10f3dd463dde8

Script:

----- Variables
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Tool = script.Parent
local animation = script:WaitForChild("SwingAnim")
local CanSwing = true
local Swinging = false

local Settings = {
	SwingTime = 0.5,
	Damage = 15,
}

----- Functions
Tool.Activated:Connect(function()
	if CanSwing then
		Swinging = true
		print("Activated")
		local animtrack = Character:WaitForChild("Humanoid"):LoadAnimation(animation)
		animtrack:Play()
		CanSwing = false
		Tool.Handle.Touched:Connect(function(hit)
			if game.Players:GetPlayerFromCharacter(hit.Parent) then
				Tool:WaitForChild("R"):FireServer("Hit",hit.Parent,Settings.Damage)
			end
		end)
		wait(Settings.SwingTime)
		CanSwing = true
		Swinging = false
	end
end)

1 answer

I can't find an error in your script, but someone else may. It seems to me that it may be an issue with your animation. Try and go into editor and make sure everything is correct there?

1 comment

0

It works perfectly in the editor and nothing is wrong with it idk why it isn't working

This discussion is preserved as it was. New answers, comments, and votes are closed.