Forsaken RP game problem

INTRODUCTION

Hi guys! I’ve got a problem with a forsaken roleplay game that i’m creating.

THE PROBLEM

As i’ve stated, i’ve got a problem with the game, and the problem are actually a ton of them. But here is the main one, the main one is that probably because everything i’m doing is on server, sometimes, when 2 players morph at the same time, it basically breaks the morph of the other player and the player that morphed first.

CODES

Morph script inside server script server:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ReloadCharacterEvent = ReplicatedStorage.LoadCharacterEvent

local SurvivorsFolder = game.ReplicatedStorage.Survivors
local KillersFolder = game.ReplicatedStorage.Killers

ReloadCharacterEvent.OnServerEvent:Connect(function(Player, Button)
	local Character = SurvivorsFolder:FindFirstChild(Button.Name) or KillersFolder:FindFirstChild(Button.Name)
	local CharacterClone = Character:Clone()
	
	if game.StarterPlayer:FindFirstChild("StarterCharacter") then
		game.StarterPlayer.StarterCharacter:Destroy()
	end
	
	local NewAnimate = CharacterClone:FindFirstChild("Animate"):Clone()
  	local NewAbility = ReplicatedStorage.Abilities:FindFirstChild(CharacterClone.Name):Clone()
	
	CharacterClone.Name = "StarterCharacter"
	CharacterClone.Parent = game.StarterPlayer
	
	task.wait(0.5)
	Player:LoadCharacter()
	if Player.Character:FindFirstChild("Animate") then
		Player.Character.Animate:Destroy()
	end
	if Player.PlayerGui:FindFirstChild("Abilities") then
		Player.PlayerGui:FindFirstChild("Abilities"):Destroy()
	end
	task.wait(0.1)
	if NewAbility then
		NewAbility.Parent = Player.Character
	end
	if CharacterClone:FindFirstChild("Abilities") then
		CharacterClone.Abilities.Parent = Player.PlayerGui
	end
	NewAnimate.Parent = Player.Character
end)

Client script on a gui:

local StarterPlayer = game:GetService("StarterPlayer")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ReloadCharacterEvent = ReplicatedStorage:WaitForChild("LoadCharacterEvent") 

local UI = script.Parent
local CharacterTypeFrame = UI.CharacterType
local UIPageLayout = UI.UIPageLayout

local SurvivorsButton = CharacterTypeFrame.Survivors
local KillersButton = CharacterTypeFrame.Killers

local SurvivorsFrame = UI.Survivors
local KillersFrame = UI.Killers

UI.Visible = true

SurvivorsButton.MouseButton1Up:Connect(function()
	UIPageLayout:JumpTo(UI.Survivors)
end)

KillersButton.MouseButton1Up:Connect(function()
	UIPageLayout:JumpTo(UI.Killers)
end)

for i, v in pairs(SurvivorsFrame:GetChildren()) do
	if v:IsA("ImageButton") then
		v.MouseButton1Up:Connect(function()
			task.wait(0.1)
			ReloadCharacterEvent:FireServer(v)
			UI.Visible = false
		end)
	end
end

for i, v in pairs(KillersFrame:GetChildren()) do
	if v:IsA("ImageButton") then
		v.MouseButton1Up:Connect(function()
			task.wait(0.1)
			ReloadCharacterEvent:FireServer(v)
			UI.Visible = false
		end)
	end
end

END

How can i solve this?

you should name the clones in StarterCharacter the name of the player

It automatically renames to the player’s character name, starter character is something to make the player’s appearance change, so just making the character’s name different, won’t change anything, in fact, it’ll not even register as a custom character

if game.StarterPlayer:FindFirstChild("StarterCharacter") then
	game.StarterPlayer.StarterCharacter:Destroy()
end

this deletes the other player’s character

I don’t think this will be a solution…

when the first character clones, it checks for an existing clone, doesn’t find it, and then clones. when the second character clones, it checks for an existing clone, finds the first character’s clone and destroys it, and then clones

1 Like

Pretty good logic, but still, i don’t think this is a solution because server takes a bit long to respond, which means, at the time that the player morphs, it’s already too late for the destroy

no, the character is cloned before the delays

1 Like

oh, makes sense, so that may be the solution, ill make sure to warn you if it works