Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does my model delete itself and respawn me after a few seconds?

Hi so I am a beginner scripter and I'm attempting to make a titan shifting script from 'Attack On Titan. I made the basics of it and it works all the way into shifting into the actual model that I can move with. After a few seconds though the model disappears and I get respawned.

The following is the code used to transform into the model:

local NewCharacter = game.Workspace.AT --(Model, stored in Workspace to troubleshoot this)
		NewCharacter:Clone()
		NewCharacter.Parent = workspace
		game.Workspace:WaitForChild("AT")
		wait()
		Player.Character = game.Workspace.AT

Like I said, after a few seconds it just respawns me and deletes the entire model from the Workspace. Any help with this would be appreciated as I have been struggling on this for hours and my knowledge of scripting is not yet good enough to fix this error myself.

2 answers

Please use the code as LocalScript.

First, at line 4, no need to use :WaitForChild since it's already loaded.

At line 6, instead of Player.Character, use game:GetService("Players").LocalPlayer.Character

I hope this helps, thank you!

3 comments

0

Unfortunately this did not fix my issue. I cannot use this as a local script because it's apart of an actual script (Which contains all of the code for the transformation) that activates by RemoteEvent using a local script.. I did try to replace the Player.Character with your suggestion but I was given the error "'attempt to index nil with 'Character' ".

0

Sorry but I tried my best to help! I will contact other person soon to fix your problem ASAP. Thanks for reading!

0

It's alright! Thank You for taking the time to respond and try to help me anyway.

That's a simple mistake even I sometimes make to this day, you forgot to set the clone to a variable. And you also assigned the character to the original model, and not the clone.

local NewCharacter = game.Workspace.AT:Clone()
NewCharacter.Parent = workspace
wait()
game.Players.LocalPlayer.Character = NewCharacter

2 comments

0

So this did fix the issue of the model not being cloned, thank you for that. But the issue with me being respawned and the clone deleting itself persists. Could it be the model itself? I've tried other models and they have worked with this. Or would it be a scripting error at this point?

0

I really can't tell you what would be going wrong because I don't know what you're doing other than what you provided.

This discussion is preserved as it was. New answers, comments, and votes are closed.