So I am making a teleport system for a few players in my game so that they can move around the map sufficiently. However, I want it so they must be touching a certain part called "Teleport1" which is located in game.Workspace.Teleports.Teleport1
. However, the following script allows the players to teleport whenever they want regardless if they are touching a part or not because i'm unsure how to add the touch function into this code and then to register it when the player says the command.
local isAdmin = {[14946581] = true, [28433911] = true, [51013956] = true} PC = script.Places.PotionClass TC = script.Places.TransfigClass Dor = script.Places.Dorm Te = script.Places.Teams A = script.Effect.A B = script.Effect.B C = script.Effect.C D = script.Effect.D E = A:Clone() F = B:Clone() G = C:Clone() H = D:Clone() function onChatted(message, player) if message:sub(1, 5):lower() == ("Floo/"):lower()and isAdmin[player.UserId] then for _, child in pairs(player.Character:GetChildren()) do if child:IsA("BasePart") then spawn(function() if message:sub(6):lower() == (PC.Value):lower() then local E2 = E:Clone() local F2 = F:Clone() local G2 = G:Clone() local H2 = H:Clone() E2.Parent = child F2.Parent = child G2.Parent = child H2.Parent = child wait(.5) player.Character.HumanoidRootPart.CFrame = (CFrame.new(PC.Location.Value)) wait(1) E2:Remove() F2:Remove() G2:Remove() H2:Remove() --Transfig class-- elseif message:sub(6):lower() == (TC.Value):lower() then local E2 = E:Clone() local F2 = F:Clone() local G2 = G:Clone() local H2 = H:Clone() E2.Parent = child F2.Parent = child G2.Parent = child H2.Parent = child wait(.5) player.Character.HumanoidRootPart.CFrame = (CFrame.new(TC.Location.Value)) wait(1) E2:Remove() F2:Remove() G2:Remove() H2:Remove() --Potion class-- elseif message:sub(6):lower() == (Dor.Value):lower() then local E2 = E:Clone() local F2 = F:Clone() local G2 = G:Clone() local H2 = H:Clone() E2.Parent = child F2.Parent = child G2.Parent = child H2.Parent = child wait(.5) player.Character.HumanoidRootPart.CFrame = (CFrame.new(Dor.Location.Value)) wait(1) E2:Remove() F2:Remove() G2:Remove() H2:Remove() --Potion class-- elseif message:sub(6):lower() == (Te.Value):lower() then local E2 = E:Clone() local F2 = F:Clone() local G2 = G:Clone() local H2 = H:Clone() E2.Parent = child F2.Parent = child G2.Parent = child H2.Parent = child wait(.5) player.Character.HumanoidRootPart.CFrame = (CFrame.new(Te.Location.Value)) wait(1) E2:Remove() F2:Remove() G2:Remove() H2:Remove() end end) else end end end end game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(message) onChatted(message, player) end) end)
Anyone have any ideas?
Thank you.
https://scriptinghelpers.org/help/community-guidelines
Do not be a jerk.
Malicious or targeted repeated reputation changes are not permitted.
If you attempt to downvote this answer, you will see you have no reason to do so because I have changed it.
This question is days old (previously working on this before the question was posted), and I have been working on fixing it with her this entire time. If you think I am suggesting that you use deprecated functions just because I'm using her code as an example of what to do, then you are being over critical.
local isAdmin = {[14946581] = true, [28433911] = true, [51013956] = true} PC = script.Places.PotionClass TC = script.Places.TransfigClass Dor = script.Places.Dorm Te = script.Places.Teams local fireplace = {} --would be a table containing all the explorer path's to the floor parts in a fireplace. A = script.Effect.A B = script.Effect.B C = script.Effect.C D = script.Effect.D E = A:Clone() F = B:Clone() G = C:Clone() H = D:Clone() function onChatted(message, player) if message:sub(1, 5):lower() == ("Floo/"):lower()and isAdmin[player.UserId] then fireplace[0].Touched:Connect(function(hit) if player == hit then a(player, message) end end end end game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(message) onChatted(message, player) end)--AAAAAH IT WAS NOT PROPERLY INDENTED, THE WORLD'S GOING TO END!!!! end)
I just wrapped what you had there in a touched event just after the chat command event.
THIS IS THE ONLY EXPLANATION NEEDED, ALL SHE ASKED WAS WHERE TO PLACE IT!