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

How do i add a whitelist for only players in this script? please help!

Asked by 4 years ago

local Teleport = "tp2" --Put the name of the Part between the ""s. function Touch(hit) --Indicates that the Part has been Touched. if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true --Checks Debounce. local Pos = script.Parent.Parent:findFirstChild(Teleport) --Gets the Part to teleport to. hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end --Takes you there and Ends the Function. script.Parent.Touched:connect(Touch) --Listens out for Touchers.

this is a teleporting script how do i add a whitelist to this script to make it only teleport players and not parts?

0
Please format your code. Edit this question then highlight all the code you have and press the blue Lua circle button one time. You should see many ~ appear, just save the question and you should be set! alphawolvess 1784 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

I rewrote your code.

local teleport = workspace:FindFirstChild("tp2") -- You may want to look elsewhere for this if it's not directly in "workspace".
local isPad = false -- Change this to "true" if your "tp2" is a pad, else leave it as is. 

script.Parent.Touched:Connect(function(hit)
    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        if isPad == true then
            hit.Parent.HumanoidRootPart.CFrame = CFrame.new(teleport.Position.X, (teleport.Position.Y + 6), teleport.Position.Z)
        else
            hit.Parent.HumanoidRootPart.CFrame = CFrame.new(teleport.Position)
        end
    end
end)

If this helps, you're welcome.

Ad

Answer this question