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 get a UserID and make a door collide for that specific userID?

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

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

2 comments

0

A solution with ColissionGroups would be fancier and better for the user

0

Still hasn't worked

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

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