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

The animation does work in studio, but not in the actual game?

I made a script so that when the player joins, if they type something they have an animation play on their character.

When I uploaded the animation MYSELF to Roblox under my name, the type of animation was Action. And no, this game is not in a group

Code:

 prefix = "/e " -- Put any prefix here, with a space

game.Players.PlayerAdded:connect(function(p)
	p.Chatted:connect(function(m)
		m = m:lower()
		if m == prefix.."hardlaugh" then
			-- Creating the animation --
			local a = Instance.new("Animation",p.Character)
			a.AnimationId = "rbxassetid://6334058346"
			local c = p.Character
			local h = c:FindFirstChild('Humanoid')
			
            -- Playing the animation --
			local t = h:LoadAnimation(a)
			t:Play()
			local w = h.WalkSpeed
			h.WalkSpeed = 0
			wait(7.65)
			h.WalkSpeed = w
			--elseif m == prefix.."" then
			--Code, basically if you want to make another chatted event
		end
	end)
end)

Something wrong with my code in any way?

1 answer

I don't know exactly what is going wrong but there is something I would change, when ever I access the Character from the server I ALWAYS just search for the players name and make sure it is a model because the ** Player.Character ** function never really seems to work for me.

My personal revisions below, let me know if this works.

 prefix = "/e " -- Put any prefix here, with a space

game.Players.PlayerAdded:connect(function(p)
    p.Chatted:connect(function(m)
        m = m:lower()
        if m == prefix.."hardlaugh" then
            -- Creating the animation --
            local a = Instance.new("Animation",workspace:FindFirstChild(p.Name))
            a.AnimationId = "rbxassetid://6334058346"
            local c = workspace:FindFirstChild(p.Name)
            local h = c:FindFirstChild('Humanoid')

            -- Playing the animation --
            local t = h:LoadAnimation(a)
            t:Play()
            local w = h.WalkSpeed
            h.WalkSpeed = 0
            wait(7.65)
            h.WalkSpeed = w
            --elseif m == prefix.."" then
            --Code, basically if you want to make another chatted event
        end
    end)
end)

1 comment

0

Oof, didn't work :|. Thanks for helping though

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