GetPlayerFromCharacter is not valid part of player


Why does script not work?
Script:

local first = nil
local second = nil
local third = nil
local fourth = nil
local cooldown = false

local queepart = script.Parent


queepart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and cooldown == false then
		if hit.Parent.Name ~= second and hit.Parent.Name ~= third and hit.Parent.Name ~= fourth and first == nil then
			cooldown = true
			workspace.Endless1:Fire()
			first = hit.Parent
			print("first logged in")
			hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-42.371, 48.757, 0.76)
			wait(1)
			cooldown = false
		end
	end
end)

queepart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and cooldown == false then
		if hit.Parent.Name ~= first and hit.Parent.Name ~= third and hit.Parent.Name ~= fourth and second == nil and first ~= nil then
			cooldown = true
			second = hit.Parent
			print("second logged in")
			hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-42.371, 48.757, 0.76)
			wait(1)
			cooldown = false
		end
	end
end)


queepart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid")and  cooldown == false then
		if hit.Parent.Name == hit.Parent.Name ~= first and hit.Parent.Name ~= second and hit.Parent.Name ~= fourth and third == nil and second ~= nil then
			cooldown = true
			third = hit.Parent
			print("third logged in")
			hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-42.371, 48.757, 0.76)
			wait(1)
			cooldown = false
		end
	end
end)


queepart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and cooldown == false then
		if hit.Parent.Name ~= second and hit.Parent.Name ~= third and hit.Parent.Name ~= first and fourth == nil and third ~= nil then
			cooldown = true
			fourth = hit.Parent
			print("fourth logged in")
			hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-42.371, 48.757, 0.76)
			wait(1)
			cooldown = false
		end
	end
end)

script.Parent.SurfaceGui.TextLabel.Changed:Connect(function()
	if script.Parent.SurfaceGui.TextLabel.Text == "0" then
		local TS = game:GetService("TeleportService")
		local Players = game:GetService("Players")

		local code = TS:ReserveServer(8882985920)
		local player1 = first:GetPlayerFromCharacter()
		local player2 = second:GetPlayerFromCharacter()
		local player3 = third:GetPlayerFromCharacter()
		local player4 = fourth:GetPlayerFromCharacter()
		local players = player1 and player2 and player3 and player4

		TS:TeleportToPrivateServer(game.PlaceId,code,players)
	end
end)

please help

local player1 = Players:GetPlayerFromCharacter(first)

Players:GetPlayerFromCharacter (roblox.com)

2 Likes

it is

game:GetService("Players"):GetPlayerFromCharacter(Model) 
 

and not

Model:GetPlayerFromCharacter()

i am sure that’s the issue.