What i mean by buttons is parts with proximity prompt inside of them
ohhh okayyy so you would need to add a bool value to check if both players have pressed it
yes i want to do exactly that and if both values are true swap their locations/places
Try this:
local TpButtons = script.Parent
local bluePressed = TpButtons:FindFirstChild("BluePressed")
local orangePressed = TpButtons:FindFirstChild("OrangePressed")
local blueTp = TpButtons.BlueTp:FindFirstChild("TpPositionPart")
local orangeTp = TpButtons.OrangeTp:FindFirstChild("TpPositionPart")
local bluePp = TpButtons.BlueTp.TpButton:FindFirstChild("ProximityPrompt")
local orangePp = TpButtons.OrangeTp.TpButton:FindFirstChild("ProximityPrompt")
bluePp.Triggered:Connect(function(plr)
if script.Parent.Orange and script.Parent.Orange.Value ~= plr then
bluePressed.Value = true
script.Parent.Blue.Value = plr
print("inserted 1", plr.Name)
end
end)
orangePp.Triggered:Connect(function(plr)
if script.Parent.Blue and script.Parent.Blue.Value ~= plr then
orangePressed.Value = true
script.Parent.Orange.Value = plr
print("inserted 2", plr.Name)
end
end)
while task.wait() do
if orangePressed.Value and bluePressed.Value then
script.Parent.Orange.Value.Character:PivotTo(CFrame.new(orangeTp.Position))
script.Parent.Blue.Value.Character:PivotTo(CFrame.new(blueTp.Position))
orangePressed.Value = false
bluePressed.Value = false
end
end
I took the script from your rbxm file.
unfortunately this did not work i think the script has to be constantly checking if both are activated
add two object values in the same parent as the script and name one “Blue” and the other one “Orange”
Yikes, what a dumpster fire of bad info this thread has become.
@Egegold0, your code has two main logic errors:
- The
swapPlayers
function will never execute becausebluePressed.Value
andorangePressed.Value
are never bothtrue
simultaneously. -
LastTriggered
is not a property ofProximityPrompt
and it doesn’t appear to be aValueBase
instance either. Even if it did exist, you are never assigning its value – meaning you aren’t keeping track of which player pressed the button last.
This is why you shouldn’t be using ChatGPT to write code for you. Learn how to write the code yourself or you’ll just be back here again tomorrow asking for help with code you can’t read, and you’ll never be able to create anything meaningful.
I’ve identified the issues in “your” code, but I’m not going to write the code that fixes them for you because I’m not going to encourage you to leech off of other people’s work instead of learning it yourself.
Still doesn’t work unfortunately
Actually i already know coding i tried multiple scripts that I myself wrote and deleted and rewrite everytime but it didn’t work so my last chance was chatgpt i asked chatgpt to modify my code to make it work and it wrote that soo yeah
These two statements are very much at odds with each other.
Test the solutions I gave and you’ll find that it works.
Well im not like ‘‘Professional coder that can code anything given’’ but i know like the basics and I can make almost every basic stuff like teleporters, BUT I kinda didn’t know how to code the thing im trying to solve right now. So im asking devforum for a little help don’t you mind?
Send screenshot of the folder of the buttons., also we here ate giving you a script that you can edit to work in your game, not a ready to go script.
How can I find the player that last activated the proximity prompt? do i need to make a table and put the players name in it
Is the Proximity Prompts names correct?
Im pretty sure that their name’s are correct
here you go:
TpButtons.rbxm (5.0 KB)
Edit: I forgot I spoon-fed you the script so examine and learn from it ok?
Don’t worry i will learn some stuff with the code that you provided, Thanks. trying it rn
It works!!! thank you so much i will learn stuff from this code!
I will try to add a countdown and some texts to your script