#All my teleportation scripts stopped working after i edited my transition script

1 messages · Page 1 of 1 (latest)

violet kraken
#

As the title says, all my teleportation scripts stopped working after i added stuff to my transition script and i'm unsure why. I went to older versions of my games too and the teleportation no longer works.

real tendonBOT
#

studio** You are now Level 3! **studio

violet kraken
#

what it used to look like before i added the transition (it worked with transition for a while before it randomly stopped)

ember plume
#

first of all

#

put these scripts here by

#

typing three `

#

then putting lua after these three `

#

Second of all

#

Not a problem, js a generic thing

#

Learn how to make your scripts more readable

#

As you can see in your script

#

you have

#

game.ReplicatedStorage.ShowDreamTransition

#

You should've put for example:

local RS = game:GetService("ReplicatedStorage")

RS.ShowDreamTransition.blablabla
#

Third of all

#

Not a solution for your problem yet!!!

#

What you are doing here is...

#

"if teleportlocation == 1 then"

#

you wanna say a question

#

how is that wrong

#

well, you copied that 4 times

#

until you get

#

"if teleportlocation == 4 then"

#

what you can do is

#
if teleportlocation == 1 then -- js ur logic here yk
    blablabla
elseif 2 -- js ur logic here yk

elseif 3 -- js ur logic here yk

elseif 4 -- js ur logic here yk
end
#

Fourth of all

#

Finally a solution

#

of your script

#

Solution:

local prox = script.Parent.ProximityPrompt
local teleportLocations = {
    workspace.PotentialDreams.one.home,
    workspace.PotentialDreams.two.home,
    workspace.PotentialDreams.three.home,
    workspace.PotentialDreams.four.home
}

local function teleportPlayer(player)
    local teleportLocation = teleportLocations[math.random(1, #teleportLocations)]
    game.ReplicatedStorage.ShowDreamTransition:FireClient(player)
    task.wait(0.5)
    player.Character.HumanoidRootPart.CFrame = teleportLocation.CFrame
end

prox.Triggered:Connect(function(player)
    teleportPlayer(player)
end)
local remoteevent = game.ReplicatedStorage.ShowDreamTransition

remoteevent.OnClientEvent:Connect(function()
    local tweenService = game:GetService("TweenService")
    local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
    local parent = script.Parent
    local dream = parent.Dream
    local txtLabel = parent.TeleportTxt

    local function fadeOut()
        local fadeout = tweenService:Create(parent, tweenInfo, {BackgroundTransparency = 1})
        fadeout:Play()
    end

    local function fadeIn()
        local fadein = tweenService:Create(parent, tweenInfo, {BackgroundTransparency = 0})
        local fadeinImage = tweenService:Create(dream, tweenInfo, {ImageTransparency = 0})
        fadeinImage:Play()
        fadein:Play()
    end

    local function showLabel()
        txtLabel.Visible = true
    end

    local function hideLabel()
        txtLabel.Visible = false
    end

    fadeIn()
    showLabel()
    task.wait(5)
    fadeOut()
    hideLabel()
end)
#

If doesn't work - tell me.

#

try this, this contains print statements.:

local prox = script.Parent.ProximityPrompt
local teleportLocations = {
    workspace.PotentialDreams.one.home,
    workspace.PotentialDreams.two.home,
    workspace.PotentialDreams.three.home,
    workspace.PotentialDreams.four.home
}

local function teleportPlayer(player)
    print("Teleporting player...")
    local location = teleportLocations[math.random(1, #teleportLocations)]
    print("Location:", location.Name)
    print("Player Character:", player.Character)
    print("HumanoidRootPart:", player.Character.HumanoidRootPart)
    player.Character.HumanoidRootPart.CFrame = location.CFrame
    print("CFrame set to:", location.CFrame)
end

prox.Triggered:Connect(function(player)
    print("Proximity prompt triggered by player:", player.Name)
    teleportPlayer(player)
end)
#

Check if some of prints don't work

violet kraken
#

TYSM! i'm not the most familiar with proper code structure so this helped a lot. Also the teleporation works now! ty again!!!