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

how can i stop a script that edits a character from repeating every time a new player joins?

Asked by 5 years ago

i added a script i found on google to my game to replace character model names however it repeats every time a new player joins which would constantly respawn a player, how can i fix this?

01game.Players.PlayerAdded:Connect(function(player)
02    local ignore = false
03    player.CharacterAdded:connect(function(oldCharacter)
04        wait(1)
05        if ignore then return end
06        ignore = true
07        spawn(function()
08            player.Character = nil
09            oldCharacter.Archivable = true
10            local newCharacter = oldCharacter:Clone()
11            newCharacter.Name = player.PlayerNameValue.Value
12            player.Character = newCharacter
13            newCharacter.Parent = workspace
14            if newCharacter:FindFirstChildOfClass("ForceField") then
15                while oldCharacter:FindFirstChildOfClass("ForceField") do
View all 26 lines...
0
Maybe use `break` User#29913 36 — 5y
0
@LinkTheHero what you can do is place a script in `StarterCharacterScripts`. Scripts in here will be automatically cloned and placed into the character making is so that everytime a character spawns it will run the code. BlackOrange3343 2676 — 5y
0
move 'ignore' outside of both functions DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Delete line 2 'local'.

Local is a thing that unable to change so you have to delete it for creating a changeable variable.

Comment below if you keep having problems, I just find that out :V

Ad

Answer this question