Teleporting won't work

The code is in a LocalScript.

local player = game:GetService("Players").LocalPlayer
local hum = player.Character:WaitForChild("Humanoid")
local TS = game:GetService("TweenService")

local TeleportColorCorrection = Instance.new("ColorCorrectionEffect")
TeleportColorCorrection.Parent = game.Lighting

function TeleportFlash()
	TeleportColorCorrection.Brightness = 1
	TS:Create(TeleportColorCorrection, TweenInfo.new(1), {Brightness = 0}):Play()
	TeleportColorCorrection:Destroy()
end

local SecretPartDebounce = false
local SecretTeleporterDebounce = false

Map.Geometry.SecretPart.Touched:Connect(function()
	if SecretPartDebounce == false then
		SecretPartDebounce = true
		game.Workspace.Sounds.SecretPart:Play()
		Map.Geometry.SecretPart.Transparency = 0.7
	end
end)

game.Workspace.SecretTeleporter.Touched:Connect(function()
	if SecretTeleporterDebounce == false then
		SecretTeleporterDebounce = true
		game.Workspace.Sounds.SecretTeleporter:Play()
		spawn(TeleportFlash())
		local Character = player.Character or player.CharacterAdded:Wait()
		Character:PivotTo(CFrame.new(game.Workspace.SecretTeleportTo.Position))
	end
end)

The script plays the sound but doesn’t do the flash or the teleportation. How do I fix this?

local player = game:GetService("Players").LocalPlayer
local hum = player.Character:WaitForChild("Humanoid")
local TS = game:GetService("TweenService")
local Character = player.Character or player.CharacterAdded:Wait()
local TeleportColorCorrection = Instance.new("ColorCorrectionEffect")
TeleportColorCorrection.Parent = game.Lighting

function TeleportFlash()
	TeleportColorCorrection.Brightness = 1
	TS:Create(TeleportColorCorrection, TweenInfo.new(1), {Brightness = 0}):Play()
	TeleportColorCorrection:Destroy()
end

local SecretPartDebounce = false
local SecretTeleporterDebounce = false

Map.Geometry.SecretPart.Touched:Connect(function()
	if SecretPartDebounce == false then
		SecretPartDebounce = true
		game.Workspace.Sounds.SecretPart:Play()
		Map.Geometry.SecretPart.Transparency = 0.7
	end
end)

game.Workspace.SecretTeleporter.Touched:Connect(function()
	if SecretTeleporterDebounce == false then
		SecretTeleporterDebounce = true
		game.Workspace.Sounds.SecretTeleporter:Play()
		spawn(TeleportFlash)
		
		Character:SetPrimaryPartCFrame(CFrame.new(game.Workspace.SecretTeleportTo.Position))
	end
end)

Try using SetPrimaryPartCFrame

2 Likes

Minor coding mistake. Here’s what I fixed for you, try it and tell me later if it works. :coffee:

local player = game:GetService("Players").LocalPlayer
local hum = player.Character:WaitForChild("Humanoid")
local TS = game:GetService("TweenService")

local TeleportColorCorrection = Instance.new("ColorCorrectionEffect")
TeleportColorCorrection.Parent = game.Lighting

function TeleportFlash()
	TeleportColorCorrection.Brightness = 1
	TS:Create(TeleportColorCorrection, TweenInfo.new(1), {Brightness = 0}):Play()
        wait(1)
	TeleportColorCorrection:Destroy()
end

local SecretPartDebounce = false
local SecretTeleporterDebounce = false

Map.Geometry.SecretPart.Touched:Connect(function()
	if SecretPartDebounce == false then
		SecretPartDebounce = true
		game.Workspace.Sounds.SecretPart:Play()
		Map.Geometry.SecretPart.Transparency = 0.7
	end
end)

game.Workspace.SecretTeleporter.Touched:Connect(function()
	if SecretTeleporterDebounce == false then
		SecretTeleporterDebounce = true
		game.Workspace.Sounds.SecretTeleporter:Play()
		coroutine.resume(coroutine.create(function()
                     TeleportFlash()
                end))
		local Character = player.Character or player.CharacterAdded:Wait()
		Character:PivotTo(CFrame.new(game.Workspace.SecretTeleportTo.CFrame))
	end
end)
1 Like

What exactly did u change?

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