Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GetPlayerFromCharacter is not a valid member of Data Model? [closed]

Asked by 3 years ago

This question already has an answer here:

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)
0
hold up you alr asked this >.> NGC4637 602 — 3y

Marked as Duplicate by NGC4637, Soban06, radiant_Light203, and appxritixn

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 3 years ago

: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)
0
Read the documentation for player service here: https://developer.roblox.com/en-us/api-reference/class/Players radiant_Light203 1166 — 3y
Ad