Hi im making a teleport thing while you hold E and it teleports you. I was wondering how to make it actualy teleport. Im using Proximity Prompts. if possible I need to know how to make text pop up saying teleport, just the fire event.
local ProximityPromptService = game:GetService("ProximityPromptService")
local function onPromptTriggered(promptObject, player)
player.Parent:MoveTo(Vector3.new(-333.16, -1.43, 6.83))
wait(0.4)
end
ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)
Not sure why you are trying to get two parameters out of an event that only returns one. Always reference API documentation since it can clear up a lot of things.
And note, this returns the Player instance, not the Character instance.
Sorry, I made a mistake in my previous reply. I glanced over that you were using ProximityService instead of the ProximityPrompt.
But the same still applies with your “player” parameter (The value that the function is using). If you want to move the player you have to get it’s character. By doing player.Character and then finding the Humanoid in the player’s Character.
You need to define the right Instance to call the MoveTo function on. (Humanoid will make the player walk to the location). If you want to make the player teleport I would advice not using MoveTo and instead opting to change the CFrame of the HumanoidRootPart.
local ProximityPromptService = game:GetService("ProximityPromptService")
local function onPromptTriggered(promptObject, player)
if player.Character then
player.Character.Humanoid:MoveTo(Vector3.new(-333.16, -1.43, 6.83))
end
end
ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)
As you already know, PromptTriggered returns a player parameter. However, the parent of any player is “Players”. You would need to use player.Character if you are trying to refer to the player’s character.
local ProximityPromptService = game:GetService(“ProximityPromptService”)
local function onPromptTriggered(promptObject, player)
player.Character.HumanoidRootPart.Position = Vector3.new(-333.16, -1.43, 6.83)
wait(0.4)
end
I used player.Character.HumanoidRootPart.Position because Models don’t directly have a “Position” property. Doing player.Character.Humanoid:MoveTo(Vector3.new(-333.16, -1.43, 6.83)) would also work. You can ALSO use Model:SetPrimaryPartCFrame as an alternative to HumanoidRootPart.Position.
Hey @jackthehunter25! I was just trying to create the same sort of deal, implementing doors that will teleport you to the other side upon triggering a proximity prompt for my game!
I happened to find this tutorial; I hope it helps you as it has helped me.