When the player presses the button, he gets transformed into an arachnid. Now the arachnid has animations which have been uploaded, but whenever I transform, the Arachnid does not animate.
Button script;
script.Parent.MouseButton1Down:connect(function()
workspace.RemoteEvent.transform:FireServer("Arachnid") --Change name to model as needed
end)
The Server Event script (which has a remoteevent named ‘transform’ parented to it;
repeat wait() until script.transform
script.transform.OnServerEvent:connect(function(player, monster)
local c = game.ServerStorage.CharacterModels[monster]:Clone()
c.Name="StarterCharacter"
c.Parent=game.StarterPlayer
player:LoadCharacter()
print(c)
wait(.1)
c:remove()
end)
Now there is a local script inside the arachnid, named “Other” (which does not get actived for some reason), which searches for the original animate script, deletes it, then enables the Arachnid animations. This does not happen, why is that?
Other script;
for i,child in pairs(script.Parent:GetChildren()) do
if child.Name == 'Animate' then
child:Destroy()
print('hi')
script.Parent.Animate2.Disabled = false
end
end
I did not notice the edit. It’s best to reply so that others can see the notification.
For scripts in the character, you have to place them under game.StarterPlayer.StarterCharacterScripts in order for them to be placed within the model.
To help you since this does not take much time, here is what your new code should look like:
Server:
local starterP = game.StarterPlayer
repeat
wait()
until script.transform
script.transform.OnServerEvent:connect(function(player, monster)
local c = game.ServerStorage.CharacterModels[monster]:Clone()
c.Name =" StarterCharacter"
c.Parent = starterP
-- Now we place the scripts into the Starter Character Scripts.
c.Animate2.Parent = starterP.StarterCharacterScripts
c.OnKeyAnim.Parent = starterP.StarterCharacterScripts
c.Other.Parent = starterP.StarterCharacterScripts
player:LoadCharacter()
print(c)
wait(.1)
c:remove()
-- Now we remove them just like the model.
starterP.StarterCharacterScripts.Animate2.Parent = nil
starterP.StarterCharacterScripts.OnKeyAnim.Parent = nil
starterP.StarterCharacterScripts.Other.Parent = nil
end)
Other’s Script:
repeat
wait()
until script.Parent.Animate2 -- Added this since 'Other' may load before 'Animate2.'
for i, child in pairs(script.Parent:GetChildren()) do
if child.Name == 'Animate' then
child:Destroy()
print('hi')
script.Parent.Animate2.Disabled = false
end
end
NOTE: Make sure the Animate2 script is a local script, otherwise, the animations will not play.