Humanoid is not a valid member of Players "Players"

Hello,

So I’m trying to make it so once the phone call’s dialogue ends, the player gets teleported to a part called “DarkRoomPad”. The way the script works is originally from a .Touched script that I have which I tweaked a bit to try to get it to work with a ProximityPrompt doing ProximityPrompt.Triggered but I haven’t had much luck with that as I keep getting this error now and I’m not sure how to fix it:

image

The line in the script that it’s talking about:

I’ve tried messing around with it, comparing it to the .Touched version of the script to see if I did something wrong, and also looking the problem up on the DevForums but nothing seems to work for me in this case. Here’s the script:

local phone = script.Parent
local dialogue = phone.Dialogue
local proximity = phone.ProximityPrompt
local RealisticFlashlight = game.StarterGui:WaitForChild("RealisticFlashlight")
local DarkRoomPad = game.Workspace.DarkRoomPad
local teleportLocation = CFrame.new(DarkRoomPad.CFrame.X, DarkRoomPad.CFrame.Y + 5, DarkRoomPad.CFrame.Z)
debounce = false


proximity.Triggered:Connect(function(triggered)
	if triggered and triggered.Parent and triggered.Parent.Humanoid and triggered.Parent.currentlyTeleporting.Value == false then
		local Character = triggered.Parent
		local teleportLocation = CFrame.new(DarkRoomPad.CFrame.X, DarkRoomPad.CFrame.Y + 5, DarkRoomPad.CFrame.Z)
		local Character = triggered.Parent
		local player = game.Players:GetPlayerFromCharacter(triggered.Parent)
		local teleportingValue = Character.currentlyTeleporting
		proximity.Enabled = false
		dialogue:Play()
		dialogue.Ended:Wait()
		Character:SetPrimaryPartCFrame(teleportLocation)
		local teleportingValue = Character.currentlyTeleporting
		teleportingValue.Value = true
		script:Destroy()
		debounce = false
	end
end)

Nothing too crazy but what am I doing wrong? How can I make it find the Humanoid with proximity.Triggered similar to how it would with .Touched?

1 Like

Change:

To:

and triggered.Character:FindFirstChild("Humanoid")
3 Likes

triggered.Parent is PlayerService aka Players,
triggered is the PlayerInstance, PlayerInstances have a property called .Character under them that refers to the Player’s Character.

So use

triggered.Character.Humanoid

Though you want to check if the Humanoid is inside the character so use:

triggered.Character:FindFirstChildWhichIsA("Humanoid")
2 Likes

Thanks, doesn’t show said error anymore but after the changes it now says

image

image

It didn’t say this with the other scripts that currentlyTeleporting was included in. Does it have to do something with the Humanoid again?

1 Like

Replace triggered.Parent with triggered as triggered.Parent is a Service, triggered is the actual player.

triggered.currentlyTeleporting.Value == false

Btw if currentlyTeleporting has not been created by the server, it’ll have an error like that. So you’d need to create it in a server

E.g.
Inside a PlayerService.PlayerAdded connection create a new instance called BoleanValue

1 Like

Done now.

Yeah there’s already the BoleanValue “currentlyTeleporting” in StarterCharacterScripts that the game has been using for this player teleporting stuff without a problem before.

image

It’s still giving a similar error to the previous one though triggered.Parent has already been replaced with just triggered as suggested
image

1 Like

I am pretty sure a proximity prompt returns a player, not a character. If you want to find a players character, do Player.Character. Hope this helps!

1 Like

It is because the value is in the character, not the player instance. Change the value to StarterPlayerScripts (that is assuming in understood correctly)

2 Likes

Alrighty, got rid of that issue now at last. Looks like I’m getting a new one though afterwards

image
image

local phone = script.Parent
local dialogue = phone.Dialogue
local proximity = phone.ProximityPrompt
local RealisticFlashlight = game.StarterGui:WaitForChild("RealisticFlashlight")
local DarkRoomPad = game.Workspace.DarkRoomPad
local teleportLocation = CFrame.new(DarkRoomPad.CFrame.X, DarkRoomPad.CFrame.Y + 5, DarkRoomPad.CFrame.Z)
local currentlyTeleporting = game.StarterPlayer.StarterCharacterScripts.currentlyTeleporting
debounce = false


proximity.Triggered:Connect(function(triggered)
	if triggered and triggered.Parent and triggered.Character:FindFirstChildWhichIsA("Humanoid") and currentlyTeleporting.Value == false then
		local Character = triggered.Parent
		local teleportLocation = CFrame.new(DarkRoomPad.CFrame.X, DarkRoomPad.CFrame.Y + 5, DarkRoomPad.CFrame.Z)
		local Character = triggered.Parent
		local player = game.Players:GetPlayerFromCharacter(triggered.Parent)
		local teleportingValue = currentlyTeleporting
		proximity.Enabled = false
		dialogue:Play()
		dialogue.Ended:Wait()
		Character:SetPrimaryPartCFrame(teleportLocation)
		local teleportingValue = currentlyTeleporting
		teleportingValue.Value = true
		script:Destroy()
		debounce = false
	end
end)

This is what the script looks like now. How would I be able to fix this? I’ve seen it keep popping up too a few times.

1 Like

You still did not change the Character variable. Also very sorry for late response.

2 Likes

Change

local Character = triggered.Parent

to

local Character = triggered.Character

Also you make the character variable twice… you don’t need to

local Character = triggered.Parent
local teleportLocation = CFrame.new(DarkRoomPad.CFrame.X, DarkRoomPad.CFrame.Y + 5, DarkRoomPad.CFrame.Z)
local Character = triggered.Parent -- this isnt necessary
2 Likes