How to make sure the animation script stays when morphing?

  1. What do you want to achieve?
    there is three problems at hand, when resetting as the Cheerer or Spookler morph the “force field” parts will detach from the body and roll away, i want to keep them together on death and not have the body parts roll away. i have them jointed, i don’t know if weld does much different, and if i union them then the entire body just becomes a force field. is there another way to keep that gradient effect there?
    thing two, you can’t hold any tools in the current model and i don’t know why. when doing the btools command it will just spawn at 0,0,0 but still be in the inventory, but you can’t use it either. i want to fix it for combat purposes as well as to use btools and hold items while using this morph.
    thing one, the animations don’t load onto the morph when changing and i don’t know how to add it into the morph, clone it, and then run it along when morphing into the other characters.

  2. What is the issue?

  3. What solutions have you tried so far?
    because from a previous post someone helped with my animations code, the tutorial i was trying doesn’t work anymore and i don’t know where to go from here. i am just making this game for fun and don’t know much about coding,

local model = script.Parent
local prompt = model["Morph Change"].ProximityPrompt

prompt.Triggered:Connect(function(player)
	local oldCharacter = player.Character
	local newCharacter = model.Spookler:Clone()

	newCharacter.HumanoidRootPart.Anchored = false
	newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)

	player.Character = newCharacter
	newCharacter.Parent = workspace
end)

this is the code for the morph used

local RunService = game:GetService("RunService")


local character = script.Parent
local RootPart = character:FindFirstChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local walkAnim: AnimationTrack = animator:LoadAnimation(character:WaitForChild('Walking'))
walkAnim.Priority = Enum.AnimationPriority.Action
walkAnim.Looped = true

local jumpAnim: AnimationTrack = animator:LoadAnimation(character:WaitForChild('Jumping'))
jumpAnim.Priority = Enum.AnimationPriority.Action

local idleAnim: AnimationTrack = animator:LoadAnimation(character:WaitForChild('Idle'))
idleAnim.Priority = Enum.AnimationPriority.Idle
idleAnim.Looped = true


humanoid.Running:Connect(function(speed)
	if speed > .1 then 
		if not walkAnim.IsPlaying then
			walkAnim:Play()
		end
		walkAnim:AdjustSpeed(speed/16)
	else
		if walkAnim.IsPlaying then 
			walkAnim:Stop()
		end
	end
end)

humanoid.StateChanged:Connect(function(old,new)
	if new == Enum.HumanoidStateType.Jumping then
		jumpAnim:Play()
	elseif new == Enum.HumanoidStateType.Landed then
		jumpAnim:Stop()
	end
end)

idleAnim:Play()

this is the localscript used in the startercharacterscript when spawning in as the startercharacter

Try changing this to

local model = script.Parent
local prompt = model["Morph Change"].ProximityPrompt

prompt.Triggered:Connect(function(player)
	local oldCharacter = player.Character
	local newCharacter = model.Spookler:Clone()
	
	local animateScript = oldCharacter:FindFirstChild("Animate")
	if animateScript then -- checks if the animate script exists
		animateScript.Archivable = true -- makes sure that the script can be cloned
		animateScript:Clone().Parent = newCharacter -- clones (duplicates) it and puts it into the new character
	end

	newCharacter.HumanoidRootPart.Anchored = false
	newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)

	player.Character = newCharacter
	newCharacter.Parent = workspace
	oldCharacter:Destroy() -- just destroys the old character so its not left in the workspace
end)

This essentially just checks if the old character has an animate script and if it does, it will just clone (duplicate) it and put it into the new character. Also, remember to destroy the old character at the end.

An alternative is simply putting the animate scripts inside of the morphs in studio. This would be simpler, but you would have to do this for every morph.

1 Like

yea the animation still isn’t loading, i wouldn’t mind putting the animation script into each model there isn’t too many

Hmmm.

Alright try that and if that doesn’t work, we can troubleshoot.


this is how i entered it in, i’m not sure if this is exactly correct, but it doesn’t work either way i just copied my local script from the starter character, dragged the animation ids “idle” “walking” and “jumping” and put it into the spookler model as well

my only worry is that because this morph has a click e button that maybe that is messing it all up? but it isn’t IN the spookler morph it’s just grouped together in general?

Oh bruh. You named it LocalScript.

This was checking for a script named “Animate”. I would request that you try to read and understand the code before pasting it (and if you need help, please ask!!!). Just rename your script to “Animate” and the script I provided above should work. Also, put your animate script in StarterCharacterScripts.

Hmm. Are you getting any errors or warnings in the output? Could you add some debug prints to that script?

i also wanna ask is the roblox ai tool for this stuff any good? i feel bad for wanting to use it but it’s also a tool in roblox studios? and yea lemme do that rq and see if it works

I don’t think the in-built AI tool is very good for this kind of stuff, but I haven’t really tested it that much. I only use it for code autocomplete. However, AI in general can be a huge game changer - especially for beginners. Just don’t overuse it and try to actually understand the code, or you’ll stay a beginner and reliant on AI forever. Honestly, this is applicable with every use of generative AI.

1 Like

hmm alright, well i can see if it does do any help and look into what it’s actually doing from there. though i would MUCH rather be a builder then a coder as i enjoy that tons more then coding, if it were possible it would be cool to have a group of people who enjoy glaggleland as much as i do working on this whole thing, but if it’s just a one man project then so be.

Problem is ownership and work distribution. I would say scripting is (arguably) far more crucial to the game than building. Even if they are passionate about this glaggleland thing, I don’t think people would be happy to do the “important” work without having ownership or making the largest profit, when they could just do it in their own game.

yea, no i get that which is why i’m mostly doing this by myself as i have NO means of paying anyone, being in college and everything. i wish i could i would give 50% of the pay to coders as that is the meat of the game, the brain, the brawns, while building is just the skin

this is what came up so far? it slightly works with this code that the ai made? it just buffers between animation and it feels like the code is just trying too much to get what it needs to get done? like i feel like it could be simpler

local spookler = script.Parent
local humanoid = spookler:FindFirstChildOfClass("Humanoid")
if not humanoid then return end

local idleAnim = spookler:FindFirstChild("Idle")
local walkAnim = spookler:FindFirstChild("Walking")
local jumpAnim = spookler:FindFirstChild("Jumping")

local idleTrack, walkTrack, jumpTrack

if idleAnim then
    idleTrack = humanoid:LoadAnimation(idleAnim)
end
if walkAnim then
    walkTrack = humanoid:LoadAnimation(walkAnim)
end
if jumpAnim then
    jumpTrack = humanoid:LoadAnimation(jumpAnim)
end

local currentTrack = nil

local function playTrack(track)
    if currentTrack and currentTrack.IsPlaying then
        currentTrack:Stop()
    end
    currentTrack = track
    if currentTrack then
        currentTrack:Play()
    end
end

-- Handle running/walking/idle
humanoid.Running:Connect(function(speed)
    if humanoid:GetState() == Enum.HumanoidStateType.Jumping then
        return -- Don't interrupt jump animation
    end
    if speed > 0.1 then
        playTrack(walkTrack)
    else
        playTrack(idleTrack)
    end
end)

-- Handle jumping and landing
humanoid.StateChanged:Connect(function(_, newState)
    if newState == Enum.HumanoidStateType.Jumping then
        playTrack(jumpTrack)
    elseif newState == Enum.HumanoidStateType.Landed or newState == Enum.HumanoidStateType.Running then
        -- Resume idle/walk based on speed
        if humanoid.MoveDirection.Magnitude > 0.1 then
            playTrack(walkTrack)
        else
            playTrack(idleTrack)
        end
    end
end)

-- Play idle on start
playTrack(idleTrack)

This is almost the exact same thing I did…
Welp. This shouldn’t have that jittery effect:

local spookler = script.Parent
local humanoid = spookler:FindFirstChildOfClass("Humanoid")
if not humanoid then return end

local idleAnim = spookler:FindFirstChild("Idle")
local walkAnim = spookler:FindFirstChild("Walking")
local jumpAnim = spookler:FindFirstChild("Jumping")

local idleTrack, walkTrack, jumpTrack

if idleAnim then
    idleTrack = humanoid:LoadAnimation(idleAnim)
end
if walkAnim then
    walkTrack = humanoid:LoadAnimation(walkAnim)
end
if jumpAnim then
    jumpTrack = humanoid:LoadAnimation(jumpAnim)
end

local currentTrack = nil

local function playTrack(track)
    if currentTrack and currentTrack.IsPlaying then
        currentTrack:Stop()
    end
    currentTrack = track
    if currentTrack and not currentTrack.IsPlaying then
        currentTrack:Play()
    end
end

-- Handle running/walking/idle
humanoid.Running:Connect(function(speed)
    if humanoid:GetState() == Enum.HumanoidStateType.Jumping then
        return -- Don't interrupt jump animation
    end
    if speed > 0.1 then
        playTrack(walkTrack)
    else
        playTrack(idleTrack)
    end
end)

-- Handle jumping and landing
humanoid.StateChanged:Connect(function(_, newState)
    if newState == Enum.HumanoidStateType.Jumping then
        playTrack(jumpTrack)
    elseif newState == Enum.HumanoidStateType.Landed or newState == Enum.HumanoidStateType.Running then
        -- Resume idle/walk based on speed
        if humanoid.MoveDirection.Magnitude > 0.1 then
            playTrack(walkTrack)
        else
            playTrack(idleTrack)
        end
    end
end)

-- Play idle on start
playTrack(idleTrack)
1 Like

yea thanks! now i’m assuming if i want to put this into the other morphs i’ll just change the

local spookler = script.Parent
local humanoid = spookler:FindFirstChildOfClass("Humanoid")
if not humanoid then return end

to the morph i want to change it to? example

local giggler = script.Parent
local humanoid = giggler:FindFirstChildOfClass("Humanoid")
if not humanoid then return end
1 Like

You can, but you don’t have to. That’s just the variable name. You could just call it morph for all of the scripts.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.