I am using a module script for the transformations of the players in the game. Basically, objects are placed into the character and modified, and an animation plays. The first transformation’s animation works just fine, but the power’s animation refuses to play. I wasn’t able to find an error (or maybe I wasn’t looking hard enough, I am new to scripting).
I have tried using Humanoid.Animator:LoadAnimation() instead of just Humanoid:LoadAnimation() since I saw it was deprecated but that also didn’t work.
This may be an issue of the script being parented directly to the StarterGui since I had problems when it was on a ScreenGui that had ResetOnSpawn to false (it would not update any of the player’s BoolValues if the character resets).
Here is how the buttons are organized:
Here is how that function script looks like:
local plr = script.Parent.Parent
local values = plr.Character:FindFirstChild("Values")
local function Transform()
if values.Transformed.Value == false and values.Transforming.Value == false then
if plr.Character:WaitForChild("Relique").Number.Value == 1 then
local Module = require(game.ReplicatedStorage.Modules.Transformations.Panther)
Module.Transform(plr)
elseif plr.Character:WaitForChild("Relique").Number.Value == 3 then
local Module = require(game.ReplicatedStorage.Modules.Transformations.Panda)
Module.Transform(plr)
end
elseif values.Transformed.Value == true and values.Transforming.Value == false then
if plr.Character:WaitForChild("Relique").Number.Value == 3 then
local Module = require(game.ReplicatedStorage.Modules.Transformations.Panda)
Module.Detransform(plr)
elseif plr.Character:WaitForChild("Relique").Number.Value == 1 then
local Module = require(game.ReplicatedStorage.Modules.Transformations.Panther)
Module.Detransform(plr)
end
end
end
local function Power1()
if values.Transformed.Value == true and values.Transforming.Value == false then
if plr.Character:WaitForChild("Relique").Number.Value == 1 then
local Module = require(game.ReplicatedStorage.Modules.Transformations.Panther)
Module.Decimate(plr)
else
end
end
end
script.Parent.HeroUI.Gameplay.LeftPrimaryBar.Transform.MouseButton1Click:Connect(Transform)
script.Parent.HeroUI.Gameplay.LeftPrimaryBar.Power1.MouseButton1Click:Connect(Power1)
Here is the associated module for the script above.
local Panther = {}
Panther.Transform = function(plr)
local assets = game.ServerStorage.ModuleData.Transformations.Creation
local anim = assets.Animation
local playanim = plr.Character.Humanoid.Animator:LoadAnimation(anim)
plr.Character.HumanoidRootPart.Anchored = true
plr.Character.Values.Transforming.Value = true
local fxTS = assets.fxTorsoShine:Clone()
local fxTW = assets.fxTorsoWaves:Clone()
local fxSound = assets.rdTransform:Clone()
fxTS.Parent = plr.Character.HumanoidRootPart.RootAttachment
fxTW.Parent = plr.Character.HumanoidRootPart.RootAttachment
fxSound.Parent = plr.Character.HumanoidRootPart
fxSound.Playing = true
local fxBody1 = assets.fxSparkle:Clone()
local fxBody2 = assets.fxSparkle:Clone()
local fxBody3 = assets.fxSparkle:Clone()
local fxBody4 = assets.fxSparkle:Clone()
local fxBody5 = assets.fxSparkle:Clone()
fxBody1.Parent = plr.Character["Left Arm"]
fxBody2.Parent = plr.Character["Right Arm"]
fxBody3.Parent = plr.Character["Left Leg"]
fxBody4.Parent = plr.Character["Right Leg"]
fxBody5.Parent = plr.Character["Torso"]
local tShirt = assets.rdShirt:Clone()
local tPants = assets.rdPants:Clone()
playanim:Play()
task.wait(0.75)
plr.Character.Relique.Gem.fxActivated:Emit(20)
plr.Character.Relique.Gem.Transparency = 0
task.wait(0.75)
plr.Character.Relique.Gem.fxActivate:Emit(1)
task.wait(2)
plr.Character.Relique.Gem.fxActivated:Emit(20)
plr.Character.Relique.Gem.Color = Color3.fromRGB(196, 40, 28)
plr.Character.Relique.Gem.Charge.Transparency = 0
task.wait(3)
plr.Character.rdMask.fxActivated:Emit(20)
task.wait(0.25)
plr.Character.rdMask.Transparency = 0
task.wait(1.25)
plr.Character.rdEars.fxActivated:Emit(20)
task.wait(0.25)
plr.Character.rdEars.Transparency = 0
task.wait(1)
plr.Character.rdStaff.fxSparkle:Emit(40)
fxBody1:Emit(200)
fxBody2:Emit(200)
fxBody5:Emit(400)
fxBody3:Emit(200)
fxBody4:Emit(200)
task.wait(0.25)
tShirt.Parent = plr.Character
plr.Character.Torso.Material = "Metal"
plr.Character["Left Arm"].Material = "Metal"
plr.Character["Right Arm"].Material = "Metal"
if plr.Character:FindFirstChild('Shirt') then
plr.Character.Shirt.Parent = plr.Character.Storage
end
tPants.Parent = plr.Character
plr.Character["Left Leg"].Material = "Metal"
plr.Character["Right Leg"].Material = "Metal"
if plr.Character:FindFirstChild('Pants') then
plr.Character.Pants.Parent = plr.Character.Storage
end
plr.Character.rdStaff.Transparency = 0
plr.Character.rdStaff.Glow.Transparency = 0
wait(2.25)
fxTS.Rate = 0
fxTW.Rate = 0
wait(3)
fxTS:Destroy()
fxTW:Destroy()
fxSound:Destroy()
playanim:Stop()
plr.Character.Humanoid.WalkSpeed = 40
plr.Character.Humanoid.JumpHeight = 25
plr.Character.HumanoidRootPart.Anchored = false
plr.Character.Values.Transformed.Value = true
plr.Character.Values.Transforming.Value = false
end
Panther.Detransform = function(plr)
plr.Character.HumanoidRootPart.Anchored = true
plr.Character.Values.Transforming.Value = true
local fxBody1 = plr.Character["Left Arm"].fxSparkle
local fxBody2 = plr.Character["Right Arm"].fxSparkle
local fxBody3 = plr.Character["Left Leg"].fxSparkle
local fxBody4 = plr.Character["Right Leg"].fxSparkle
local fxBody5 = plr.Character["Torso"].fxSparkle
plr.Character.Relique.Gem.fxActivated:Emit(20)
plr.Character.rdMask.fxActivated:Emit(20)
plr.Character.rdEars.fxActivated:Emit(20)
task.wait(0.1)
fxBody1:Emit(200)
fxBody2:Emit(200)
fxBody5:Emit(400)
plr.Character.rdStaff.fxSparkle:Emit(40)
plr.Character.rdMask.Transparency = 1
plr.Character.rdEars.Transparency = 1
plr.Character.Relique.Gem.Transparency = 1
plr.Character.Relique.Gem.Charge.Transparency = 1
plr.Character.Relique.Gem.Color = Color3.fromRGB(0,0,0)
task.wait(0.25)
fxBody3:Emit(200)
fxBody4:Emit(200)
if plr.Character.Storage:FindFirstChild('Shirt') then
plr.Character.Storage.Shirt.Parent = plr.Character
end
plr.Character.Torso.Material = "Plastic"
plr.Character["Left Arm"].Material = "Plastic"
plr.Character["Right Arm"].Material = "Plastic"
plr.Character.rdShirt:Destroy()
plr.Character.rdStaff.Transparency = 1
plr.Character.rdStaff.Glow.Transparency = 1
task.wait(0.25)
if plr.Character.Storage:FindFirstChild('Pants') then
plr.Character.Storage.Pants.Parent = plr.Character
end
plr.Character["Left Leg"].Material = "Plastic"
plr.Character["Right Leg"].Material = "Plastic"
plr.Character.rdPants:Destroy()
wait(0.75)
fxBody1:Destroy()
fxBody2:Destroy()
fxBody3:Destroy()
fxBody4:Destroy()
fxBody5:Destroy()
plr.Character.Humanoid.WalkSpeed = 15
plr.Character.Humanoid.JumpHeight = 7.2
plr.Character.HumanoidRootPart.Anchored = false
plr.Character.Values.Transformed.Value = false
plr.Character.Values.Transforming.Value = false
end
Panther.Decimate = function(plr)
local assets = game.ServerStorage.ModuleData.Transformations.Creation
local animD = assets.Animation
local playanim = plr.Character.Humanoid.Animator:LoadAnimation(animD)
plr.Character.HumanoidRootPart.Anchored = true
plr.Character.Values.Transforming.Value = true
local fxTS = assets.fxTorsoShine:Clone()
local fxTW = assets.fxTorsoWaves:Clone()
local fxSound = assets.rdTransform:Clone()
fxTS.Parent = plr.Character.HumanoidRootPart.RootAttachment
fxTW.Parent = plr.Character.HumanoidRootPart.RootAttachment
wait(3)
fxTS.Rate = 0
fxTW.Rate = 0
wait(3)
fxTS:Destroy()
fxTW:Destroy()
fxSound:Destroy()
playanim:Stop()
plr.Character.Humanoid.WalkSpeed = 40
plr.Character.Humanoid.JumpHeight = 25
plr.Character.HumanoidRootPart.Anchored = false
plr.Character.Values.Transformed.Value = true
plr.Character.Values.Transforming.Value = false
print("this is the end of the function")
end
return Panther
As you can see here, the function runs in its entirety: