Character Morph issue

Basically what im trying to do is to switch character morphs with function. Apparently output gives an error ‘attempt to index nil with ‘CFrame’’

Script type - local (StarterCharacterScripts), error received on line 46, morph is being taken from replicated storage.

Any help appreciated!
image (3)

2 Likes

Is because you did player:FindFirstChild(“HumanoidRootPart”) instead of char:FindFirstChild(“HumanoidRootPart”). Also I recommend you wait for the character so it doesn’t error or yield the code if it hasn’t loaded. May I ask why are you putting the morphs CFrame the player’s if you switching morphs? Why can’t you use StarterCharacter.

6 Likes

maybe use :WaitForChild() instead? it could be that the part isn’t loaded correctly.

question: do you want the morphing to be client sided? (only client can see changes)
cuz if you dont want a hacker to just morph into any morphs they want then you should do it on serverside.

and last thing: you set up “char” wrong, now it redefines the VARIABLE and not the CHARACTER and destroys the new variable!

fixed code:

local function MonsterTransform()
local Morphs = RS.Morphs
local Root = Player.Character:WaitForChild("HumanoidRootPart")
local MorphChar = Morphs:FindFirstChild("Werewolf"):Clone()
MorphChar.HumanoidRootPart.CFrame = Root.CFrame
MorphChar.Parent = Workspace
Player.Character:Destroy()
Player.Character = MorphChar
end
5 Likes

I WAS FIRST HERE! you dirty man! i was already solving this and you decided to steal this! not cool man! I already reported you for this!
DONT DO THIS AGAIN!
Okay? DONT BE DIRTY LIKE THIS!

1 Like

I- I agree with the code but not the indentation or that last sentiment-

1 Like

People, settle down, you all were seen in trying to help, no worries.
Also Sam your script helped by the way, but now the UI disappeared for some reason and camera is just being anchored on same position…
Any ideas how come?

2 Likes

the morphing is on client side, should be on serverside to prevent these issue’s

1 Like

So its better to do thru the SSS/workspace thing?

2 Likes

yes, I always do that to, I am working on some scripts related to morphing and everything is going fine so far with everything being in serverstorage.

you should not use workspace since its not safe for hackers. and people will see the models stored.

i can lend you the script if you want.

1 Like

Thanks a lot!
That would be nice :slight_smile:

1 Like

these scripts are very long, I do not want them to fall into people’s hands that just passed by, I can send it trough discord if you need
send friend request to my profile: Atebread

2 Likes

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