Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by
d1_rek 46
4 years ago
Edited 4 years ago

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.

0
No didnt work maddiesswrld 30 — 4y
0
Can you tell me the errors it gave you? d1_rek 46 — 4y
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, d1_rek 46 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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)

Answer this question