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

How do I get a UserID and make a door collide for that specific userID?

Asked by 2 years ago
Edited 2 years ago

What I'm trying to do is to make a specific piece (part) phase so a specific userID (My userID) may only be able to go through it, this is the code (I put it in as a LocalScript) -

local player = game.Players.LocalPlayer
local id = 17427977

    if player.UserId == 17427977 then
    part = script.Parent



    part.Touched:connect(function(hit)

                Part.CanCollide = false
            Part.Transparency = .5
            wait(1)
            Part.CanCollide = true
            Part.Transparency = 0
        end
    end 
end



2 answers

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago
local player = game.Players.LocalPlayer
local id = 17427977

part.Touched:connect(function(hit)

    part = script.Parent
        if player.UserId == 17427977 then
         Part.CanCollide = false
         Part.Transparency = .5
            wait(1)
         Part.CanCollide = true
         Part.Transparency = 0
    end


    end 
end


try this, you might have to fiddle with some of the ends though since it got formatted a little bit weird

0
A solution with ColissionGroups would be fancier and better for the user Aimarekin 345 — 2y
0
Still hasn't worked C7Sneaky 0 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

In StarterCharacterScripts add a LocalScript which has this:

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local owner = 1 -- id

local door = workspace:FindFirstChild("Door") -- path to your door

if player.UserId == owner then
    door.CanCollide = false
end

Answer this question