Why does roblox kick all clients for "Player has been removed from datamodel"?

Hey all :slightly_smiling_face:

I was working on my game, And a bug has occured where basically, When the map loads, It kicks all players for “Player has been removed from the DataModel” (Error 291), And it kicks all clients in the game, The weird thing is if i’m testing solo, It works perfectly fine, But when my alt joins, Thats when it kicks all players. Is there a solution for this?

Here is a video of what happens:

Thanks in advance if you can help.

2 Likes

Can you provide the code for when a map loads?

1 Like
	local map = maps[random]:Clone()
	map.Parent = workspace

	status.Value = "Map chosen "..map.Name
	wait(5)

	local players = game.Players:GetChildren()
	for i = 1,#players do
		if players[i].Character ~= nil then
			local spawnLoc = math.random(1,#map.Teleports:GetChildren())
			players[i].Character:MoveTo(map.Teleports:GetChildren()[spawnLoc].Position)
			players[i].Character.Parent = workspace.Ingame
			map.Data.Music.OST:Play()
			game:GetService("ReplicatedStorage"):WaitForChild("Events").Giveitem:Fire()
			for i,v in ipairs(game.Lighting:GetChildren()) do
				v:Destroy()
			end
			for i,v in ipairs(map.Data.Lighting:GetChildren()) do
				v.Parent = game.Lighting
			end
		end
	end
1 Like

I feel like it has to do with these 2 lines of code, because error 291 states “This error is shown whenever a player was deleted/destroyed from the game server, or when the player is moved out of Players”. Why? I’m not sure… As these 2 lines look fine to me

Consider messing around with these 2 lines of code, Maybe instead of MoveTo() use PivotTo(), or other ways to write these 2 lines of code

image
I tried doing this, But it errored and broke teleportation.

Edit:

I also tried stopping the players from going to the ingame folder, To no avail

1 Like

If you want to use Pivot, try players[i].Character:PivotTo(map.Teleports:GetChildren()[spawnLoc]:GetPivot())

Edit:
Oops, forgot PivotTo()

2 Likes

image
( I added pivotto)

Neither of the options worked and errored.

Edit:

I forgot to publish lol, But I did publish, And it errored in the same way. It was removed from the data model.

1 Like

Why dont you try to simply cancel the “teleport” and first see if that actually fix the error 291 which is the reason of your post, if that works, then, you can deal with the CFraming, pivot thing

1 Like

Were you able to try removing this line in a published test? This one I think is more likely then the pivot thing:


Thats really weird, I just tried a similar version and it worked fine for me:

My quick test code to see if it would work for a single player:

game.Players:GetChildren()[1].Character:PivotTo(game.Workspace.Test:GetPivot())
1 Like

Tried that, It still didn’t work. I also tried cancelling the teleport as @Dev_Peashie suggested, And it still kicked me. I find that extremely strange.

Also as stated prior, It only kicked me on multiplayer, in studio and testing solo it works fine,

1 Like

players[i].Character.Parent = workspace.Ingame

You did it as POG suggested? could be the issue.

1 Like

I have removed the players[i].Character.Parent = workspace.Ingame line altogether, In the publish version.

1 Like

The issue could be somewhere else…
Perhaps search in your scripts?

1 Like

I haven’t found anything there, Weirdly enough; It only happened after I added the item giver script thismorning?

Okay I just tested, While testing I commented out the item giver, And it worked.

Only problem is I kind of need the item giver script for the game to work ect.

Here are the item giver scripts:

game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("Giveitem").Event:Connect(function()
	print("YESSSSSSSSSSSS IT GAVE THE ITEM")
	game:GetService("ReplicatedStorage"):WaitForChild("Events").GiveitemHandler:Fire(script.Parent.Name)
end)

Script 2:

local function giveallplayers(tool)
	for i,v in pairs(game.Players:GetPlayers()) do
		if v.Character then
			if v:FindFirstChild("Backpack") then
				if not v.Backpack:FindFirstChild(tool.Name) then
					if not v.Character:FindFirstChild(tool.Name) then
						local newtool = tool:Clone()
						newtool.Parent = v.Backpack
					end
				end
			end
		end
	end
end

local function unloadalltools()
	for i,v in pairs(game.Players:GetPlayers()) do
		if v.Character then
			if v.Character:FindFirstChildOfClass("Tool") then
				v:Destroy()
			elseif v.Backpack:FindFirstChildOfClass("Tool") then
				v:Destroy()
			
			end
		end
	end
end
game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("GiveitemHandler").Event:Connect(function(map)
	print(map)
	if map == "Roblox Classical: Swordfight" then
		giveallplayers(script.Sword)
	end
end)

game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("GiveitemHandler").Event:Connect(function(map)
	unloadalltools()
	print("(hopefully) Unloaded!")
end)

I’ll look into this, But anything immediate that could be the issue?

1 Like

Its this right here, your destroying the player (v) in this case

3 Likes

Seems that you are destroying the player.
v Holds the Player instance from your loop
for i,v in pairs(game.Players:GetPlayers()) do

Change it to destroy the weapon not the player…

			if v.Character:FindFirstChildOfClass("Tool") then
				v.Character:FindFirstChildOfClass("Tool"):Destroy()
2 Likes

Lol, sorry didnt noticed you already answer! :yum:

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.