Hello I dont know how to fix this, but the camera only zooms out in the second try,
if you activate the proximity prompt only one time nothing happens, but if you activate it a second time it works, how do I fix it, I want it to zoom out on the first try.
local Player = game.Players.LocalPlayer
script.Parent.Triggered:Connect(function(Player)
Player.CameraMode = Enum.CameraMode.Classic
Player.CameraMinZoomDistance = 3
end)
script.Parent.Triggered:Connect(function(plr)
plr.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.teleportToOutside.Position)
end)
Hey there. It appears that you’ve attempted to connect a function to the same event for the same object. This will cause the second connect to override the first
Just tested it. Try waiting until your avatar is completely loaded, then give it a try. It should work the first time. Check out Instance | WaitForChild
Super helpful, especially in this case.
Here’s a nifty thing I learned a few years ago:
script.Parent.Triggered:Connect(function(Player)
Player.CameraMode = Enum.CameraMode.Classic
Player.CameraMinZoomDistance = 3
-- This right here
local character = Player.Character or Player.CharacterAdded:Wait()
character.HumanoidRootPart.CFrame = CFrame.new(workspace.teleportToOutside.Position)
end)
Not necessarily. Just as you have seen, by the time the character has loaded it has taken 2 times to get the proximity prompt to work. Please note that the line of code I provided accounts for both possibilities, whether the character has already loaded or not.
Also, yes, the triggered event will only run when the player object is loaded, not the character. He needs the character to be loaded since he’s about to teleport the player.
What are you talking about? You don’t need to wait for the character to be loaded using :WaitForChild() specifically for triggering a proximity prompt because the Roblox engine ensures that the character is fully loaded and available in the game before any proximity prompt events can be triggered.