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 a block that is only CanCollide = false for certain people?(Unanswered)

I have attempted to use the LOCALBIN style, but that was WAYYYYYY too extensive. Is there any other way I can make a block only CanCollide = false for certain people? -- EDIT That certain player has to be able to stand in the block while the block still is impenetrable to other players.

4 answers

Well you could if statements which work only if something is true then it works


can = {1,2,3}
a = can[(math.random(1, can))] -- In this case it makes it random

if a == 1 or a == 3 then
part.CanCollide = false
end

as you can see this is an example next im going to show something else that would probably fit what your thinking put this script in the brick

script.Parent.Touched:connect(function(hit)
plr = hit.Parent:GetPlayerFromCharacter()
if plr.Name == "Shawn" then
script.Parent.CanCollide = false
wait(0.3)
script.Parent.CanCollide = true
else
plr.Humanoid.Health = 0




end)

6 comments

0

What if the player were to stay inside? What if another player were to come along and stand there as well?

0

Ill edit mkk

0

0.3 seconds would allow the person to get in the VIP or whatever but anyone tries to get in the get killed

0

They would get trapped inside if they to long.

0

I need someone to be able to stand in it and another to stand on it at the same time.

0

I'll work on it on my desktop please wait.

Here you go. Put this in a server script and the script inside the brick you want to go through if authorized.

local authorized = {"Player1","TochiWasHere","InsertOtherNamesLikeThis"} --insert allowed people in this
local OpenTime = 2.5 --change this number for how long it will stay open
local CoolingTime = 1 --change this number for long it will cool down
local db = true
script.Parent.Anchored = true

function ChkPermiss(chr)
	if db == true then --keep it from repeating itself
		db = false
		for i,v in pairs(authorized)do --loops through list
			local human = chr.Parent:findFirstChild("Humanoid") --checks if touched player is a human
			if v == chr.Parent.Name and human then --if its human and is a player in the list then
				script.Parent.CanCollide = false --go through
				script.Parent.Transparency = .6 --set transparency [change this value if you want it diff]
				wait(OpenTime) --waits the open time
				script.Parent.CanCollide = true --closes
				script.Parent.Transparency = 0
				wait(CoolingTime) --cools down
			elseif human then --now if its just human
				print("Not Authorized!") --it will print the text in the quotations (you can delete that line if you want)
			end
		end
		db = true
	end
end


script.Parent.Touched:connect(ChkPermiss) --triggers function when touched
local part = Instance.new("Part", workspace.CurrentCamera)
ok={"wazap", "Shedletsky"}
for i, v in pairs(ok) do
if v:lower() == game.Players.LocalPlayer.Name:lower() then
part.CanCollide = false
end
end
part.Anchored = true
part.Size = Vector3.new(1,1,1)
part.CFrame = CFrame.new()
game.Players.LocalPlayer.Character.Humanoid.Died:connect(function() workspace.CurrentCamera:ClearAllChildren() end)

Okay if you are using filtering enabled THEN place this in the part you want (Local script)

local Part = script.Parent
Part.CanCollide = false
Part.Anchored = true
Part.Transparency = 1
--That Part ABOVE will not work since in local script just make sure those settings are on!


local PartClone = script.Parent:Clone()
PartClone.Anchored = true
PartClone.Position = Part.Position

--This clones it on the client! So if you do can collide true on it then it will not affect other players!
local PlayersAllowed = {"OtherPeoplesName","YourName","DoTHisToAddMorePeople"}

script.Parent.Touched:connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		local chr = plr.Character
		for i, v in pairs(PlayersAllowed) do
			if v:lower() == game.Players.LocalPlayer.Name:lower() then
				PartClone.CanCollide = false
			else
				PartClone.CanCollide = true
			end
		end
	end
end)

1 comment

0

This will make it so no one can let anyone in

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