Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

GetPlayerFromCharacter is not a valid member of Data Model?

I have this problem can anyone help me plz here is my code

local TeleportService = game:GetService("TeleportService")
local part = script.Parent



part.Touched:Connect(function(hit)
	local human = hit.Parent:FindFirstChild("Humanoid")
	if human then
		local char = hit.Parent
		local player = game.GetPlayerFromCharacter(hit.Parent) 
		TeleportService:Teleport(7092017722, player)
	end
end)

1 comment

0

hold up you alr asked this >.>

1 answer

:GetPlayerFromCharacter() can only be used from the players service. The error basically says the same thing.

This is how you use it:

local Players = game:GetService("Players")
local Character = workspace.Character
local player = Players:GetPlayerFromCharacter(Character)

print(player.Name)

1 comment

0

Read the documentation for player service here: https://developer.roblox.com/en-us/api-reference/class/Players

This discussion is preserved as it was. New answers, comments, and votes are closed.