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 answer

line 10: "local player = game.GetPlayerFromCharacter(hit.Parent)" is wrong

GetPlayerFromCharacter is a function of the player service, not game which is a DataModel.

and most functions use the colon (:) operator and not the dot (.) operator

so replace

local player = game.GetPlayerFromCharacter(hit.Parent)

with

local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

More about GetPlayerFromCharacter

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