Animations glitching when added with script

My animations in my game are glitching, I use a GUI to fire a remote event which then changes the animations on the server. The animations load, but they sort of clip into place?

Video:

Server Script which changes the animations:

local RemoteEvent = game:GetService('ReplicatedStorage').SetupEvents.GenderSelect


local function ServerEvent(Player, FemaleOrMale)
	if (FemaleOrMale == 'Female') then
	local animate =	Player.Character:FindFirstChild("Animate")
		animate.run.RunAnim.AnimationId = "rbxassetid://9438134768"
		animate.idle.Animation1.AnimationId = "rbxassetid://9750337322"
		animate.idle.Animation2.AnimationId = "rbxassetid://9750337322"
		Player.Character:FindFirstChild("PlayerConfig").Gender.Value = 'Female'
	elseif (FemaleOrMale == 'Male') then
		local animate =	Player.Character:FindFirstChild("Animate")
		animate.run.RunAnim.AnimationId = "rbxassetid://9741977712"
		animate.idle.Animation1.AnimationId = "rbxassetid://9752998959"
		animate.idle.Animation2.AnimationId = "rbxassetid://9752998959"
		Player.Character:FindFirstChild("PlayerConfig").Gender.Value = 'Male'
	end
end

RemoteEvent.OnServerEvent:Connect(ServerEvent)

any help is appreciated

2 Likes

each roblox animate script that is mainly responsible for the core animations of a player controlled character are always made to be ā€œlocal scriptsā€

since you’re only using a GUI, you can simply copy and erase the server script and paste the content in the local and it will not glitch longer as server-sided replications have latencies

if you mean do it all in a local script, i can’t.

i want the animations to show for everyone, but if i just do it in a local script, it will only change for the player who clicked the gui

no no, animations replicate to the server automatically so it will work

1 Like

okay i’ll try it, thank you!

charactersssssss

i’m getting this error

Players.AdSomnum.PlayerGui.GenderSelect.Frame.Female.test:2: attempt to index nil with ā€˜Character’

right, may you show the script

script.Parent.MouseButton1Click:Connect(function(Player)
local animate = Player.Character:FindFirstChild("Animate")
animate.run.RunAnim.AnimationId = "rbxassetid://9438134768"
animate.idle.Animation1.AnimationId = "rbxassetid://9750337322"
animate.idle.Animation2.AnimationId = "rbxassetid://9750337322"

end)

add a variable in the function, make it like

local player = game.Players.LocalPlayer

there’s no difference, it still clips the animations

hmm, then i think it’s a rather animation issue, you can try editing the first keyframe of the idle to be less quicker in intervals

or another note to take is to make the priority of your idle into ā€œIdleā€ and make the run animation to have more priority ā€œCoreā€

the thing is, i use these exact animations in my other games, they work perfectly. but when i try to change them in a script, they glitch

ok i know the problem now, you need to set the walk anim as well

1 Like

it works!! thank you so much :smiley:

1 Like

okay, i found an issue unfortunately

it looks fine on the CLIENT, but to other players the animations are very weird

video:

i’m not sure if it’s clear on the video, but the animations are sort of merging together to create a weird mess of idle and walking animations mixed with whatever animations the player has on their avatar

i tried changing the animations in the server script, but it made no difference

if the ā€œmergingā€ is the case, then preemptively just a check, try clearing the default animations with this code before inserting the new ones and see if it fixes the issue

local AnimationTracks = humanoid:GetPlayingAnimationTracks()
-- Stop all playing animations
for i, track in pairs (AnimationTracks) do
   track:Stop()
end

so i put this before i change the animations?

yes

[spoiler]AAAAAAAAAAAAAAAAAAAAA[/spoiler]

1 Like

this fixed the error! Thank you so much!!

1 Like