Cannot get Humanoid's Property:

Hello,

Today, I went to Roblox Studio to create a script in an object > proximityprompt to teleport players and eventually, once structuring the part for the player’s property, one there called Humanoid does not work as it prints in the output error…

local ProximityPromptService = game:GetService("ProximityPromptService")
local TeleportService = game:GetService("TeleportService")

local BBB = game.Workspace.Folder.bbb

local ProximityPrompt = script.Parent

local ProximityPrompt_BBB = {
	ProximityPrompt.ActionText == "???";
	ProximityPrompt.ClickablePrompt == true;
	ProximityPrompt.Enabled == true;
	ProximityPrompt.HoldDuration == 20;
	ProximityPrompt.KeyboardKeyCode == Enum.KeyCode.E;
}

local targetGameId = 5036207802 -- Replace with the ID of the game you want to teleport to
local targetPlace = "PlaceName" -- Replace with the name of the place you want to teleport to


-- Player's Property
local player = game.Players
local character = player:GetPlayerFromCharacter(player)
local humanoid = character:WaitForChild("Humanoid", 0)

if not (character) then
	return
end

if (humanoid) then
	print("True")
else return
end

image

If someone can help me, that would be appreciatable!

Thank you.

player is a Service!
So basically you are giving the service as the parameter of :GetPlayerFromCharacter

1 Like

this returns the player , not the character

I recommend using

local character = player.Character

How can I fix so? I have tried getting player.Character or player.CharacterAdded:Wait(), but at Roblox Studio, it prints that it is not an valid member of RBXScriptSignal as player is an RBXScriptSignal…

Furthermore, it does not appear in the script as an option, only CharacterAutoLoads as the script for the topic it is a normal script, not an LocalScript.

Use a for loop to get every single player.

for _, v in pairs(player:GetPlayers()) do
   local character = v.Character or v.CharacterAdded:Wait()
end
local ProximityPromptService = game:GetService("ProximityPromptService")
local TeleportService = game:GetService("TeleportService")

local BBB = game.Workspace.Folder.bbb

local ProximityPrompt = script.Parent

local ProximityPrompt_BBB = {
	ProximityPrompt.ActionText == "???";
	ProximityPrompt.ClickablePrompt == true;
	ProximityPrompt.Enabled == true;
	ProximityPrompt.HoldDuration == 20;
	ProximityPrompt.KeyboardKeyCode == Enum.KeyCode.E;
}

local targetGameId = 5036207802 -- Replace with the ID of the game you want to teleport to
local targetPlace = "PlaceName" -- Replace with the name of the place you want to teleport to


-- Player's Property
local player = game.Players

for _, v in pairs(player:GetPlayers()) do
	local character = v.Character or v.CharacterAdded:Wait()
	local humanoid = character:WaitForChild("Humanoid", 0)
end

local function onBeingTeleported()
	humanoid.WalkSpeed = 0
	humanoid.JumpHeight = 0
	TeleportService:TeleportToPlaceInstance(targetGameId, targetPlace, character)
end

ProximityPrompt.Triggered:Connect(function()
	onBeingTeleported()
	task.wait(1)
	print("Teleporting")
end)

I don’t think it will work for general now because it does not get further to the local function and ProximityPrompt once triggered

The only parts that are critical to the script seem to be detecting the character and the humanoid property overall, making impossible to continue further to teleport players

Use
ProximityPrompt.Triggered:Connect(function(player)
To get the player

1 Like

You are getting the player the incorrect way. Also, you are supposed to pass the player instance in the TeleportToPlaceInstance, not the character.

Here is your updated code:

local ProximityPromptService = game:GetService("ProximityPromptService")
local TeleportService = game:GetService("TeleportService")

local BBB = game.Workspace.Folder.bbb

local ProximityPrompt = script.Parent

local ProximityPrompt_BBB = {
	ProximityPrompt.ActionText == "???";
	ProximityPrompt.ClickablePrompt == true;
	ProximityPrompt.Enabled == true;
	ProximityPrompt.HoldDuration == 20;
	ProximityPrompt.KeyboardKeyCode == Enum.KeyCode.E;
}

local targetGameId = 5036207802 -- Replace with the ID of the game you want to teleport to
local targetPlace = "PlaceName" -- Replace with the name of the place you want to teleport to


local function onBeingTeleported(humanoid, plr)
	humanoid.WalkSpeed = 0
	humanoid.JumpHeight = 0
	TeleportService:TeleportToPlaceInstance(targetGameId, targetPlace, plr)
end

ProximityPrompt.Triggered:Connect(function(player) -- gets the player who triggered the prompt
	if player then -- if player exists
		local char = player.Character or workspace:FindFirstChild(player.Name) -- gets characer
		onBeingTeleported(char:FindFirstChild("Humanoid"), player) -- runs the function, as well as sending the humanoid and player arguments.
		task.wait(1)
		print("Teleporting")
	end
end)
1 Like

As said by @Rixtys99 you can just pass the player through ProximityPrompt.Triggered:Connect(function(Player)

Then you can alter the onBeingTeleported to something like this:

local function onBeingTeleported(Player)
    local Character = Player.Character
    local Humanoid = Character:FindFirstChildOfClass("Humanoid")
	humanoid.WalkSpeed = 0
	humanoid.JumpHeight = 0
	TeleportService:TeleportToPlaceInstance(targetGameId, targetPlace, character)
end

And when running the function add: onBeingTeleported(Player)

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