Hey there! I am a fairly new Roblox/Lua Developer, so I’d appreciate any Help from anyone.
I am currently trying to make a Script that Teleports the User from the Main Game to the Experience (Mission) the User has selected. However, instead I am met with the Error “exception while signaling: Teleport Service cannot be cloned” while playing on Roblox Player. I am unsure what I did wrong, since I am pretty sure I made no Errors.
Here is the Code:
-- Services
local ReplicStorage = game:GetService("ReplicatedStorage")
local TeleportService = game:GetService("TeleportService")
local SafeTeleport = require(ReplicStorage:FindFirstChild("SafeTeleportModule"))
-- Event
local TeleportEvent = ReplicStorage:FindFirstChild("TeleportEvent")
-- Place IDs
local Site29ID = 17036823509
local Area14ID = nil -- TODO: make place
-- Dictionary to Map Missions to Place IDs
local MissionMap = {
["Site 29"] = Site29ID;
["Area 14"] = Area14ID;
}
-- Function to teleport user
TeleportEvent.OnServerEvent:Connect(function(Player, Mission, Difficulty, ifSolo)
local TeleportOptions = Instance.new("TeleportOptions")
TeleportOptions.ShouldReserveServer = true
-- Sets the ID
local TeleportToID = MissionMap[Mission]
-- Table with Data to send to the Server/Experience
local TeleportData = {
Difficulty;
ifSolo;
}
-- Sends the Table to the Server
TeleportOptions:SetTeleportData(TeleportData)
-- Teleports the User to Selected Mission
SafeTeleport(TeleportToID, {Player}, TeleportOptions)
end)
How it (is supposed to) works:
- The User presses the “Begin Mission” Button, which is connected to a Local Script. The Local Script fires an Event called “TeleportEvent” with the Arguments: Mission, Difficulty, ifSolo so an Example would be (“Site 29”, “Keter”, false).
- The Event gets processed in ServerScriptService.
Regarding the SafeTeleport Thing, here is the Documention. I’ve added it as the Doc instructed, so I don’t think the SafeTeleport Function is the problem.
I was unable to find any other Discussions regarding my problem - I even checked StackOverflow. However, even when I do find a Discussion, it’s either telling me to Publish the Places (Which I did) and/or It’s just outright confusing to understand (probably cuz im stupid).
Again, help from anyone is appreciated.