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:
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?
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:
Yeah there’s already the BoleanValue “currentlyTeleporting” in StarterCharacterScripts that the game has been using for this player teleporting stuff without a problem before.
It’s still giving a similar error to the previous one though triggered.Parent has already been replaced with just triggered as suggested
It is because the value is in the character, not the player instance. Change the value to StarterPlayerScripts (that is assuming in understood correctly)
Alrighty, got rid of that issue now at last. Looks like I’m getting a new one though afterwards
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.
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