Well not entirely random, but it works sometimes, then not the other. It only happens when the game is public, so idk if it’s multiple users trying the script or something else.
Anyway, the script is like a keycard script, except when a player touches the part with an item, it will tp them to a certain place.
teleportA = script.Parent.TeleportA
teleportB = script.Parent.TeleportB
teleportA.Touched:connect(function(hit)
if canteleport == true and hit.Parent.Name == "RedGear" then
canteleport = false
wait(0.2)
hit.Parent.Parent.HumanoidRootPart.CFrame = teleportB.CFrame
wait(1)
canteleport = true
end
end)```
Is there something I should be optimizing/changing? Would like feedback.
Uhhh, no. No intertwining scripts with that tp. Only issue I can think of is either a gamepass messing w/ it or more than one person using it at once. Some servers have the issue, and some don’t.
No errors show up, cause it only happens in public lobbies and happens “randomly”. Another solution may be having the script take away the item once u touch it? Maybe that would fix something.
“:connect” is deprecated, it’s no longer supported by ROBLOX, also use “:Connect”, you didn’t make an if statement if the hit object is a character or not, it can’t find the humanoid in the parent if it doesn’t make sure it’s a character or not
it is likely that while the program is waiting you have unequipped the tool, try this:
teleportA = script.Parent.TeleportA
teleportB = script.Parent.TeleportB
teleportA.Touched:connect(function(hit)
if canteleport == true and hit.Parent.Name == "RedGear" then
canteleport = false
--wait(0.2)
hit.Parent.Parent.HumanoidRootPart.CFrame = teleportB.CFrame
wait(1)
canteleport = true
end
end)```
hope this can help you
also, if a keycard touches it or the part named “RedGear” but a character isn’t holding it and it somehow happens to, it doesn’t work + show us the error output
He said that it randomly stopped, not the fact it didn’t work from the beginning, also i doubt that’ll do anything but make it visible for all players in the server.
Not that it differs in servers, but that something suddenly causes it to stop working, or maybe clogs it so no one can use it. Once it happens it a server, it can’t be fixed. In simple words, the tp will stop working cause of something in public games, it works normally, but wtvr the bug is happens randomly, in random servers, at random times. Of course it probably has an answer that I just haven’t found. Hope I made it a little clearer