I thought about starting to create an Anti-Teleport system in my game and, so far, it is working well. I had to adapt it a lot, since my game has a teleport player system (inside the map) So far it has worked well and without any problems, however I’m testing at RobloxStudio, where I don’t have the real experience of a player playing and I’m also concerned with ping the players.I tested it and found that it can get in the way (of errors that the high ping itself generates)
an example of error is the ping itself (imagine), I recorded a video as an example:
I created a script that will teleport the player that plays to an x position (that’s all).
note that for some reason, the player goes back to an old position and takes it back to its new position.
this is a problem because the script understands it as if it had teleported, when it didn’t!
I would like to know how I could adapt my script for players who are pinging high
first script, it creates a “StringValue” in ServerScriptService (a safe place and out of reach of Exploiters) with the name of the player when he enters. In this String Value, my idea was that I could change its Value (in this case, its Text) depending on the situation in which the player was, for example, if he was playing normally on the map (without touching any teleporter) his text would be: “World” and, if he touches a teleporter, the text would be: “Teleport” to indicate that, the reason his magnitude is high is because he touched a teleporter(a legal Teleport Server System).
game.Players.PlayerAdded:Connect(function(plr)
local stringg = Instance.new("StringValue",game.ServerScriptService)
stringg.Name = plr.Name
stringg.Value = "World"
db = false
end)
workspace.teleporter.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
if db == false then db = true
hit.Parent.Humanoid.WalkSpeed = 30
local touch = game.ServerScriptService:FindFirstChild(hit.Parent.Name)
touch.Value = "Teleport"
hit.Parent.HumanoidRootPart.CFrame = workspace.GrassPlate.CFrame * CFrame.new(50,20,10)
end)
end
end)
--just below I added more parameters to the script, but I will not put it so that the post doesn't get too big (if it hasn't already)
in other scripts I asked him to check every 1 second and,if he touches another type of teleporter (to send the player back to the map),the value of StringValue would be equal to “Teleport to”.
coroutine.resume(coroutine.create(function()
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Wait()
local db = false
local character = player.Character
coroutine.resume(coroutine.create(function()
workspace.Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if db == false then db = true
game.ServerScriptService:FindFirstChild(hit.Parent.Name).Value = "Teleport to"
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(100,0,0) --(teleport player to Map)
wait() db = false
end
end
end)
end))
coroutine.resume(coroutine.create(function()
player.Character.Humanoid.Died:Connect(function()
player.CharacterAdded:Connect(function()
character = player.Character
end)
end)
end))
while wait() do
if player.Character:FindFirstChild("HumanoidRootPart") then
local pos1x = player.Character.HumanoidRootPart.Position.X
local pos1z = player.Character.HumanoidRootPart.Position.Z
local pos1 = Vector3.new(pos1x,0,pos1z)
wait(1)
if player.Character:FindFirstChild("HumanoidRootPart") then
local pos2x = player.Character.HumanoidRootPart.Position.X
local pos2z = player.Character.HumanoidRootPart.Position.Z
local pos2 = Vector3.new(pos2x,0,pos2z)
print((pos1 - pos2).magnitude)
local mag = (pos1 - pos2).magnitude
local valuer = game.ServerScriptService:FindFirstChild(player.Name).Value
if mag > 40 then
if character.Humanoid.Health > 0 then
wait()
print(valuer)
if valuer == "Teleport" then
print("okay, his magnitude is high because he touched a teleporter")
elseif valuer == "World" then
player:Kick("Teleport. Stop it!")
elseif valuer == "Teleport to" then print("all right, he just entered the world")
end
end
end
end
end
end)
end))
my question is: how would i adapt this script to ping the player? or something so that the system does not fail and ends up kicking an innocent player that has a high ping?
another doubt:I created this script from scratch, without any help, is there anything wrong with it or some way to make it better?