-
What do you want to achieve?
I have this concept of wanting to change all character movement animations when obtaining a martial art style or obtainable class. This includes walking animations, idle etc. I have managed to achieve 8 directional movement animations, all i need now is to be able to switch them by a press of a button. I also want to be able to switch all my animations when i crouch.
I have a String Value named “Pose”. When i change the value in roblox studio, it plays a different set of animations. for instance i change “Standing” to “Crouching” it plays 8 directional crouching animations. However i have seen a role playing game where you cant change your animations through a menu. How do i accomplish this?
edit: I have found the game that has this system.
Local Script:
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
repeat wait()
until script.MainModule
local AnimNums = require(script.MainModule)
local pose = script.Pose.Value
local animStyle = script.AnimationStyle.Value
local currently_playing_anim = {}
local IdleAnim = Instance.new("Animation")
local Forward = Instance.new("Animation")
local Back = Instance.new("Animation")
local Right = Instance.new("Animation")
local Left = Instance.new("Animation")
local Run = Instance.new("Animation")
local Jump = Instance.new("Animation")
local Fall = Instance.new("Animation")
local Landed = Instance.new("Animation")
IdleAnim.AnimationId = (AnimNums[animStyle][pose]["Idle"])
Forward.AnimationId = AnimNums[animStyle][pose]["Forward"]
Back.AnimationId = (AnimNums[animStyle][pose]["Back"])
Right.AnimationId = (AnimNums[animStyle][pose]["Right"])
Left.AnimationId = (AnimNums[animStyle][pose]["Left"])
Run.AnimationId = (AnimNums[animStyle][pose]["Run"])
Jump.AnimationId = (AnimNums[animStyle][pose]["Jump"])
Fall.AnimationId = (AnimNums[animStyle][pose]["Fall"])
Landed.AnimationId = (AnimNums[animStyle][pose]["Landed"])
humanoid.WalkSpeed = 8
local anim = {
["idle"] = humanoid:LoadAnimation(IdleAnim),
["frontwalk"] = humanoid:LoadAnimation(Forward),
["backwalk"] = humanoid:LoadAnimation(Back),
["rightwalk"] = humanoid:LoadAnimation(Right),
["leftwalk"] = humanoid:LoadAnimation(Left),
["frontrun"] = humanoid:LoadAnimation(Run),
["jump"] = humanoid:LoadAnimation(Jump),
["fall"] = humanoid:LoadAnimation(Fall),
["landed"] = humanoid:LoadAnimation(Landed)
}
local X,Z = 0,0
for i,v in pairs(anim) do
v:Play()
v.Looped = true
end
local function setallweight(num)
for i,v in pairs(anim) do
v:AdjustWeight(num)
end
end
humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
anim["backwalk"]:AdjustSpeed(humanoid.WalkSpeed/10)
anim["leftwalk"]:AdjustSpeed(humanoid.WalkSpeed/10)
anim["rightwalk"]:AdjustSpeed(humanoid.WalkSpeed/10)
anim["frontwalk"]:AdjustSpeed(humanoid.WalkSpeed/10)
anim["frontrun"]:AdjustSpeed(humanoid.WalkSpeed/25)
end)
local Connection
Connection = RunService.RenderStepped:Connect(function()
if not humanoid or humanoid.Health == 0 then
Connection:Disconnect()
end
local movedir = character.PrimaryPart.CFrame:vectorToObjectSpace(humanoid.MoveDirection)
local currentstate = humanoid:GetState()
X = movedir.X
Z = movedir.Z
local distZ,distZMin = ((character.PrimaryPart.CFrame.LookVector * 5) - Vector3.new(0,0,Z)).Magnitude,((character.PrimaryPart.CFrame.LookVector * -5) - Vector3.new(0,0,Z)).Magnitude
--print("X = "..movedir.X.." Z = "..movedir.Z)
if currentstate == Enum.HumanoidStateType.Jumping then
setallweight(0)
anim["jump"]:AdjustWeight(1)
elseif currentstate == Enum.HumanoidStateType.Freefall then
setallweight(0)
anim["fall"]:AdjustWeight(1)
elseif
currentstate == Enum.HumanoidStateType.Landed then
setallweight(0)
anim["landed"]:AdjustWeight(1)
else
anim["jump"]:AdjustWeight(0)
anim["fall"]:AdjustWeight(0)
anim["landed"]:AdjustWeight(0)
if Z == 0 then
anim["backwalk"]:AdjustWeight(0)
anim["frontwalk"]:AdjustWeight(0)
anim["frontrun"]:AdjustWeight(0)
elseif Z < 0 then
anim["backwalk"]:AdjustWeight(0)
if humanoid.WalkSpeed < 20 then
anim["frontwalk"]:AdjustWeight((Z*-1.1))
anim["frontrun"]:AdjustWeight(0)
else
anim["frontrun"]:AdjustWeight(Z*-1.1)
anim["frontwalk"]:AdjustWeight(0)
end
elseif Z > 0 then
anim["backwalk"]:AdjustWeight(Z*1.1)
anim["frontrun"]:AdjustWeight(0)
anim["frontwalk"]:AdjustWeight(0)
end
if X == 0 then
anim["rightwalk"]:AdjustWeight(0)
anim["leftwalk"]:AdjustWeight(0)
elseif X < 0 and not UIS:IsKeyDown(Enum.KeyCode.W) and not UIS:IsKeyDown(Enum.KeyCode.S) then
anim["rightwalk"]:AdjustWeight(X*-1.2)
anim["leftwalk"]:AdjustWeight(0)
--print(X*-1.2)
elseif X > 0 and not UIS:IsKeyDown(Enum.KeyCode.W) and not UIS:IsKeyDown(Enum.KeyCode.S) then
anim["rightwalk"]:AdjustWeight(0)
anim["leftwalk"]:AdjustWeight(X*1.2)
--print(X*1.2)
elseif X > 0 and Z > 0 then
anim["rightwalk"]:AdjustWeight(0)
anim["leftwalk"]:AdjustWeight(X*0.4)
elseif X > 0 and Z < 0 then
anim["rightwalk"]:AdjustWeight(0)
anim["leftwalk"]:AdjustWeight(X*0.4)
elseif X < 0 and Z > 0 then
anim["rightwalk"]:AdjustWeight(X*-0.4)
anim["leftwalk"]:AdjustWeight(0)
elseif X < 0 and Z < 0 then
anim["rightwalk"]:AdjustWeight(X*-0.4)
anim["leftwalk"]:AdjustWeight(0)
end
if X == 0 and Z == 0 then
anim["idle"]:AdjustWeight(1)
else
anim["idle"]:AdjustWeight(0)
end
end
end)
Module Script:
local AnimNumbers = {
["None"] =
{
["Standing"] = {
["Idle"] = "rbxassetid://10072363810";
["Forward"] = "rbxassetid://10091318742";
["Back"] = "rbxassetid://10091165873";
["Right"] = "rbxassetid://10091301747";
["Left"] = "rbxassetid://10091306376";
["Run"] = "rbxassetid://10091491032";
["Jump"] = "rbxassetid://10092374516";
["Fall"] = "rbxassetid://10092429251";
["Landed"] = "rbxassetid://10092540405"
},
["Crouching"] = {
["Idle"] = "rbxassetid://10092660985";
["Forward"] = "rbxassetid://10092807027";
["Back"] = "rbxassetid://10092960413";
["Right"] = "rbxassetid://10093187112";
["Left"] = "rbxassetid://10093173807";
["Run"] = "rbxassetid://10091491032";
["Jump"] = "rbxassetid://10092374516";
["Fall"] = "rbxassetid://10092429251";
["Landed"] = "rbxassetid://10092540405"
}
}
}
return AnimNumbers
None stands for No Style