Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

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

Asked by
Chronomad 180
9 years ago

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)
0
Maybe because character is a read only property? (just brainstorming) TheDeadlyPanther 2460 — 9y
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. Chronomad 180 — 9y
0
Does the second script run only once or every time per character loading? This depends on script location and settings. LetThereBeCode 360 — 9y

2 answers

Log in to vote
3
Answered by 9 years ago

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.

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. Perci1 4988 — 9y
0
I've added a debounce before and got nothing. I added your code to mine and the result was my client crashing. Chronomad 180 — 9y
0
@Chronomad you probably put it in wrong spot or you didn't post the real relevant code here. LetThereBeCode 360 — 9y
0
I edited the OP with the updated script. Chronomad 180 — 9y
View all comments (2 more)
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. LetThereBeCode 360 — 9y
0
I edited the OP again with the second script. Chronomad 180 — 9y
Ad
Log in to vote
-2
Answered by
Sypr 0
9 years ago

what is newplayer in storage? is it a model?

0
Use the comments? And yes it's a model. Chronomad 180 — 9y

Answer this question