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

Why am I getting this strange error? (Updated script)

This script is supposed to allow the player to control a custom character. However, whenever it runs I get this : 00:00:38.987 - startScript re-entrancy has exceeded 3 00:00:38.987 - Script 'Players.Player1.Backpack.CharMorph', Line 8

Also, whenever this script is active, it stops a second script from running.

Here is the script.

local player = game:GetService('Players').LocalPlayer
local newCharacter = game.ReplicatedStorage.newPlayer:Clone()
local SpawnLocation = game.Workspace.SpawnLocation 

local debounce = false

	player.CharacterAdded:connect(function()
		if not debounce then
       	 debounce = true

		newCharacter.Parent = game.Workspace
		newCharacter.Name = player.Name
			player.Character = newCharacter
			player.CanLoadCharacterAppearance = nil
		newCharacter.Archivable = false
	wait(1)

	debounce = false

		end
	end)

And here is the second script.

local Player = game.Players.LocalPlayer

	Player.Character.Humanoid.Running:connect(function(speed)
		  if speed > 0 then     --Straight from the Wiki!
    		print("Player is running")
				elseif speed < 1 then
  			  print("Player has stopped")
	end
end)

3 comments

0

Maybe because character is a read only property? (just brainstorming)

0

The script works in the sense that it allows the player to control the custom character. However, whenever the script is active, it stops an unrelated script from firing.

0

Does the second script run only once or every time per character loading? This depends on script location and settings.

2 answers

✓ Accepted answer

From your error, I can assume that you are binding CharacterAdded event to your function which adds a character. What i suggest is adding a debounce.

local debounce = false
player.CharacterAdded:connect(function()
	if not debounce then
		debounce = true
		
		-- code for adding a new character
		
		debounce = false
	end
end)

Hope this helped.

6 comments

0

That could likely be the case. I had the same problem when I made a custom character, because when you SET the character property it fires CharacterAdded -- causing the character to be set again, etc. etc.

0

I've added a debounce before and got nothing. I added your code to mine and the result was my client crashing.

0

@Chronomad you probably put it in wrong spot or you didn't post the real relevant code here.

0

I edited the OP with the updated script.

0

@Chronomad That seems fine, although I see you posted this comment "However, whenever the script is active, it stops an unrelated script from firing." Are you completely sure it's unrelated? I doubt so.

0

I edited the OP again with the second script.

what is newplayer in storage? is it a model?

1 comment

0

Use the comments? And yes it's a model.

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