I am trying to make a part spawn when a player plays an animation, the animation plays, but that is all I get, nothing from the output either.


local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?id=178966770"

local Player = game.Players.LocalPlayer
local Mouse =  Player:GetMouse()
local animTrack = nil
local Playername = Player.Name

Mouse.KeyDown:connect(function(key)
    if key:lower() == "q" then
        local character = Player.Character
        animTrack = character:WaitForChild("Humanoid"):LoadAnimation(animation) 
    	animTrack:Play()
		
		animTrack.KeyframeReached:connect(function(keyframeName) -- New function
			if keyframeName == 2 then -- When it gets to the second key frame do
				local Javalin = game.Lighting.Javalin:Clone()
				Javalin.Parent = game.Workspace
				Weld = Instance.new("Weld")
				Weld.Parent = game.Workspace.Playername["Right Arm"]
				Weld.Part0 = game.Workspace.Playername["Right Arm"]
				Weld.Part1 = Javalin
				for i=1, 40 do
					Javalin.Mesh.Scale.x = Javalin.Mesh.Scale.x +0.5
					wait(0.1)
				end
			end
		end)
	end
end)

2 comments

0

Is FilterningEnabled on? If so, you will have to make it use RemoteEvents/Functions to work properly in servers.

0

I have no idea what it is so I presume it is what it is set to as defult, but, what about the question?