I’ve recently came across an issue where in a place roulette-esque game, some game ID’s simply won’t work and I can’t find a solution. I’ve then found that I can use datastores, but the teleport is located in a local script and I’m not sure how to determine if a teleport failed if the teleport script is in the local script and would not work if it’s outside of it.
TL;DR i need a way to make a blacklisted datasore for game ids that dont work!!!
Any help would be greatly appreciated and here’s my local script code:
local players = game:GetService('Players')
local player = players.LocalPlayer
local tpservice = game:GetService('TeleportService')
local tservice = game:GetService('TweenService')
local regSSize = 1
local regSSizeFocus = 2
local regColour = Color3.fromRGB(88, 101, 242)
local info = TweenInfo.new(0.2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local er= script.Parent.Parent.error
local erroroccured = false
local erSSize = 2
local erColour = Color3.fromRGB(252, 130, 128)
local url = script.Parent.Parent.URLBox
local btn = script.Parent
local gtween1 = tservice:Create(url.UIStroke,info, {Thickness = 2})
local gtween2 = tservice:Create(url.UIStroke,info, {Thickness = 1})
btn.MouseButton1Up:Connect(function()
if player then
local function isValid(id)
local isgame
local success,message = pcall(function()
local gameid = game:GetService('MarketplaceService'):GetProductInfo(id)
isgame = gameid.AssetTypeId == 9
end)
return success and isgame
end
if isValid(url.Text) then
tpservice:Teleport(url.Text,player)
end
end
end)
url.Focused:Connect(function()
gtween1:Play()
url.FocusLost:Connect(function()
gtween2:Play()
end)
url.Changed:Connect(function()
if url.Text ~= tonumber(url.Text) then
id = tonumber(url.Text)
erroroccured = true
er.TextTransparency = 0
er.Text = 'Invalid ID / Game does not exist!'
url.UIStroke.Color = erColour
gtween1:Play()
elseif url.Text == '' and erroroccured == true then
er.Text = 'Game ID is required!'
elseif id then
-- valid
else
--invalid
end
end)
end)
There are some things like colour tweens that you dont need to worry about.
Again, any help is definitely appreciated or I can troubleshoot solo!
Not entirely sure how to incorporate it. Here’s what I did:
local tpservice = game:GetService('TeleportService')
local tservice = game:GetService('TweenService')
local regSSize = 1
local regSSizeFocus = 2
local regColour = Color3.fromRGB(88, 101, 242)
local rstorage = game:GetService('ReplicatedStorage')
local tp = rstorage.Teleport
local dds = game:GetService('DataStoreService')
local blacklist = dds:GetDataStore('Blacklist9')
local info = TweenInfo.new(0.2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local er= script.Parent.Parent.error
local erroroccured = false
local erSSize = 2
local erColour = Color3.fromRGB(252, 130, 128)
local url = script.Parent.Parent.URLBox
local btn = script.Parent
local gtween1 = tservice:Create(url.UIStroke,info, {Thickness = 2})
local gtween2 = tservice:Create(url.UIStroke,info, {Thickness = 1})
btn.MouseButton1Up:Connect(function()
game.Players.PlayerAdded:Connect(function(player)
if player then
local function isValid(id)
local isgame
local success,message = pcall(function()
local gameid = game:GetService('MarketplaceService'):GetProductInfo(id)
isgame = gameid.AssetTypeId == 9
end)
return success and isgame
end
if isValid(url.Text) then
btn.MouseButton1Up:Connect(function()
if blacklist:GetAsync(url.Text) then
btn.Text = 'Teleport Failed: Game does not exist. This has been blacklisted from appearing again!'
else
tp:FireServer(url.Text,player)
end
end)
end
end
end)
end)
url.Focused:Connect(function()
gtween1:Play()
url.FocusLost:Connect(function()
gtween2:Play()
end)
url.Changed:Connect(function()
if url.Text ~= tonumber(url.Text) then
id = tonumber(url.Text)
erroroccured = true
er.TextTransparency = 0
er.Text = 'Invalid ID / Game does not exist!'
url.UIStroke.Color = erColour
gtween1:Play()
elseif url.Text == '' and erroroccured == true then
er.Text = 'Game ID is required!'
elseif id then
-- valid
else
--invalid
end
end)
end)
local players = game:GetService('Players')
local player = players.LocalPlayer
local tservice = game:GetService('TweenService')
local regSSize = 1
local regSSizeFocus = 2
local regColour = Color3.fromRGB(88, 101, 242)
local rstorage = game:GetService('ReplicatedStorage')
local tp = rstorage.Teleport
local info = TweenInfo.new(0.2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local er= script.Parent.Parent.error
local erroroccured = false
local erSSize = 2
local erColour = Color3.fromRGB(252, 130, 128)
local url = script.Parent.Parent.URLBox
local btn = script.Parent
local gtween1 = tservice:Create(url.UIStroke,info, {Thickness = 2})
local gtween2 = tservice:Create(url.UIStroke,info, {Thickness = 1})
btn.MouseButton1Up:Connect(function()
if player then
local function isValid(id)
local isgame
local success,message = pcall(function()
local gameid = game:GetService('MarketplaceService'):GetProductInfo(id)
isgame = gameid.AssetTypeId == 9
end)
return success and isgame
end
if isValid(url.Text) then
tp:FireServer(url.Text)
end
end
end)
url.Focused:Connect(function()
gtween1:Play()
url.FocusLost:Connect(function()
gtween2:Play()
end)
url.Changed:Connect(function()
if url.Text ~= tonumber(url.Text) then
id = tonumber(url.Text)
erroroccured = true
er.TextTransparency = 0
er.Text = 'Invalid ID / Game does not exist!'
url.UIStroke.Color = erColour
gtween1:Play()
elseif url.Text == '' and erroroccured == true then
er.Text = 'Game ID is required!'
elseif id then
-- valid
else
--invalid
end
end)
end)
Next, create a server script like this (and make sure to put it in ServerScriptService):
local tpservice = game:GetService('TeleportService')
local dds = game:GetService('DataStoreService')
local blacklist = dds:GetDataStore('Blacklist9')
local rstorage = game:GetService('ReplicatedStorage')
local tp = rstorage.Teleport
tp.OnServerEvent:Connect(function(player, urlText)
-- Do whatever you want here with the data store
tpservice:Teleport(urlText, player)
end)