I’m going to assume there’s a wall that players can’t normally pass through unless they are a member of staff in your group. If they are staff, they activate a proximityprompt that only runs the code below if they are a staff member, right?
If that’s the case, I’ve revised the code. Give it a try. Also, renaming proximity prompts won’t do anything except perhaps better organization of your explorer.
The wall also needs to be in workspace, placed where you want it to be. If you want the proximity prompt to show up on the wall, make sure the proximity prompt is inside the wall. If you’re looking for an easy way for position, I’d suggest placing a part in workspace to where you want the staff members to teleport and just set the position of that part as the OppositeSidePosition.
local ProximityPrompt = script.Parent
local GroupId = 17256639
local GroupRank = 1
ProximityPrompt.Triggered:Connect(function(Player)
local Success, Result = pcall(function()
return Player:GetRankInGroup(GroupId)
end)
if Success and Result >= GroupRank then
local OppositeSidePosition = Vector3.new() --Set to the position for staff to be teleported
if Player.Character then
Player.Character:MoveTo(OppositeSidePosition)
end
end
end)
Keep in mind that the code is pretty much the same as TheRealANDRO’s, just reworded in a sense.
If you’re looking to get back to the original side when the prompt is clicked from the opposite side, it may be better to use invisible parts and just teleport staff members to those parts.
Revised version including above:
local ProximityPrompt = script.Parent
local InsidePart = workspace.Part1 -- Change to where the inner teleport should be
local OutsidePart = workspace.Part2 -- Change to where players get teleported when leaving the opposite way
local GroupId = 17256639
local GroupRank = 1
ProximityPrompt.Triggered:Connect(function(Player)
local Success, Result = pcall(function()
return Player:GetRankInGroup(GroupId)
end)
if Success and Result >= GroupRank then
local OppositeSidePosition = Vector3.new() --Set to the position for staff to be teleported
local DistanceToOutsidePart = (OutsidePart.Position - Player.Character.PrimaryPart.Position).Magnitude
local DistanceToInsidePart = (InsidePart.Position - Player.Character.PrimaryPart.Position).Magnitude
if Player.Character then
if DistanceToOutsidePart > DistanceToInsidePart then -- Teleports player based on which side they're closest to
Player.Character:MoveTo(OutsidePart.Position)
else
Player.Character:MoveTo(InsidePart.Position)
end
end
end)
Basically, it’ll just teleport the staff members to the opposite side by finding out which side is furthest away. If you can know the side they’re not on, then you can teleport them there.
Just be aware of the dimensions of the outside area for the wall you’re talking about. If players are closer to the opposite side where they get teleported by going around the wall, they can get inside anyways.
Create two parts in your workspace and set the Collision to disabled and transparency to one. Name one InsidePart and the other OutsidePart. Reference those parts in your script based off what they’re meant to do.
Where you have those parts are exactly where players will be teleported when interacting with the proximity prompt.
Nvm, I’m going to do it another way, thanks for the help! Thanks @TheRealANDRO, @thegreatdabb, and @thegreatdabb for helping me! Sorry for wasting your guys time.
local ProximityPrompt = script.Parent
local InsidePart = workspace.Part1 -- Change to where the inner teleport should be
local OutsidePart = workspace.Part2 -- Change to where players get teleported when leaving the opposite way
local GroupId = 17256639
local GroupRank = 1
ProximityPrompt.Triggered:Connect(function(Player)
local Success, Result = pcall(function()
return Player:GetRankInGroup(GroupId)
end)
if Success and Result >= GroupRank then
local OppositeSidePosition = Vector3.new() --Set to the position for staff to be teleported
local DistanceToOutsidePart = (OutsidePart.Position - Player.Character.PrimaryPart.Position).Magnitude
local DistanceToInsidePart = (InsidePart.Position - Player.Character.PrimaryPart.Position).Magnitude
if Player.Character then
if DistanceToOutsidePart > DistanceToInsidePart then -- Teleports player based on which side they're closest to
Player.Character:MoveTo(OutsidePart.Position)
else
Player.Character:MoveTo(InsidePart.Position)
end
end
end
end)