Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make if a certain rank in my group touches a block, it teleports them to another block?

I need it so if the rank 255 steps on the block, it will teleport them to another block, but if any other rank steps on it, it won't teleport them. Here is what I have in the teleport block.

local Teleport = "Teleport-2" 
local config = script.Parent.Parent.Configuration
function Touch(hit) 
	if part.Parent and game:GetService('Players'):GetPlayerFromCharacter(part.Parent) then
  local player = game:GetService('Players'):GetPlayerFromCharacter(part.Parent)
  if player:GetRankInGroup(config.GroupId.Value) >= config.RankId.Value then
	local Pos = script.Parent.Parent:findFirstChild(Teleport) 
		hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false 
script.Parent.Touched:connect(Touch) 
	end
end

2 answers

That's kind of messy so I decided to rescript it for you.

local teleport-2 = game.Workspace:FindFirstChild("TELEPORTERNAME")
local ID = 0
local RANKID = 0
local function Touched(hit)
if part.Parent and game.Players:FindFirstChild(part.Parent.Name) then
local player = game.Players:FindFirstChild(part.Parent.Name)
if player:GetRankInGroup(ID) >= RANKID then
	part.Parent:MoveTo(teleport-2)
end
end
end
script.Parent.Touched:Connect(Touched)

This should work, I'm not to sure since I didn't test.

3 comments

0

No didnt work

0

Can you tell me the errors it gave you?

0

There I edited it, should've have come easy to you. It used to be :Connect(Touch) but that wasn't a valid function. It's touched,

I changed a few things from d1_rek's answer, and it worked. Here it is if anyone needs it!

local teleport = workspace.Teleport
local ID = 6235192
local RANKID = 254
local function Touched(part)
if part.Parent and game.Players:FindFirstChild(part.Parent.Name) then
local player = game.Players:FindFirstChild(part.Parent.Name)
if player:GetRankInGroup(ID) <= RANKID then
    player.Character:MoveTo(teleport.Position)
end
end
end
script.Parent.Touched:Connect(Touched)

This discussion is preserved as it was. New answers, comments, and votes are closed.