I want to have 2 prompts and when 2 diffrent players activate it it will wait 3 seconds and the swap their positions/locations it doesn’t work here is my current code:
local TpButtons = script.Parent
local bluePressed = TpButtons:FindFirstChild("BluePressed")
local orangePressed = TpButtons:FindFirstChild("OrangePressed")
local blueTp = TpButtons:FindFirstChild("BlueTp")
local orangeTp = TpButtons:FindFirstChild("OrangeTp")
local function swapPlayers()
if bluePressed.Value and orangePressed.Value then
local bluePlayer = blueTp.TpButton:FindFirstChildOfClass("ProximityPrompt").LastTriggered
local orangePlayer = orangeTp.TpButton:FindFirstChildOfClass("ProximityPrompt").LastTriggered
if bluePlayer and orangePlayer then
local blueRoot = bluePlayer.Character and bluePlayer.Character:FindFirstChild("HumanoidRootPart")
local orangeRoot = orangePlayer.Character and orangePlayer.Character:FindFirstChild("HumanoidRootPart")
if blueRoot and orangeRoot then
local bluePosition = blueRoot.Position
local orangePosition = orangeRoot.Position
blueRoot.CFrame = CFrame.new(orangePosition)
orangeRoot.CFrame = CFrame.new(bluePosition)
print("Swapped positions of", bluePlayer.Name, "and", orangePlayer.Name)
end
end
end
end
local function onProximityPromptTriggered(prompt, player)
local character = player.Character
local humanoidRootPart = character and character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
if prompt.Parent == blueTp.TpButton then
bluePressed.Value = true
orangePressed.Value = false
elseif prompt.Parent == orangeTp.TpButton then
orangePressed.Value = true
bluePressed.Value = false
end
swapPlayers()
end
end
if blueTp and orangeTp then
local bluePrompt = blueTp.TpButton:FindFirstChildOfClass("ProximityPrompt")
local orangePrompt = orangeTp.TpButton:FindFirstChildOfClass("ProximityPrompt")
if bluePrompt and orangePrompt then
bluePrompt.Triggered:Connect(function(player) onProximityPromptTriggered(bluePrompt, player) end)
orangePrompt.Triggered:Connect(function(player) onProximityPromptTriggered(orangePrompt, player) end)
else
warn("ProximityPrompt not found in one of the TpButtons")
end
else
warn("BlueTp or OrangeTp not found in TpButtons folder")
end
ChatGPT is primarily language-based so doing logic-based stuff isn’t its strong suit. If you code use bing copilot it updates in real time and is somewhat more intelligent. Can you send the hierarchy of TpButtons? You can also send the TpButtons as a model and I’ll see what I can do.
In addition to @sonic_848 ‘s point, this also makes it so that the two values will never be true at the same time. Definitely dont have chatgpt writing scripts for you.
you aren’t actually checking anything. Here is what it should look like
if bluePressed.Value == true orangePressed.Value == true then
you can change that to fakse or true depending on what you need but I hope you understand that what I’m trying to say I’d when you say that if statement you are basically saying if blue pressed.value. But what about the value?
This same thing happens multiple times in the code and the teleport is written wrong.
There are heaps of things done wrong It’s not a good piece of code.
local TpButtons = script.Parent
local bluePressed = TpButtons:FindFirstChild("BluePressed")
local orangePressed = TpButtons:FindFirstChild("OrangePressed")
local blueTp = TpButtons:FindFirstChild("BlueTp")
local orangeTp = TpButtons:FindFirstChild("OrangeTp")
local bluePp = TpButtons:FindFirstChild("BlueProximityPrompt") -- change this to be the name of your blue proximity prompt
local OrangePp = TpButtons:FindFirstChild("OrangeProximityPrompt") -- change this to be the name of your orange proximity prompt
BluePp.Triggered:Connect(function(plr)
plr.Character:PivotTo(CFrane.new(blueTp.Position))
end
)
OrangePp.Triggered:Connect(function(plr)
plr.Character:PivotTo(CFrane.new(orangeTp.Position))
end
)
You totally understood it wrongly, there is 2 buttons when diffrent persons activate diffrent buttons that i talked about their locations/positions get swapped