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 change a blocks value only for one player?

Hello, I want to change a block so the player is able to walk through. But only one player should be able to go through there. So basicly I want to change a blocks value locally.

3 answers

There is a CanCollide property in Parts that can be triggered through Script. Here is an example of a Team door script that uses this:

Door = script.Parent
function onTouch()
	if Door:FindFirstChild("Humanoid") ~= nil then
		player = game.Players:GetPlayerFromCharacter(Door)
		if player.TeamColor = BrickColor.new("Bright blue") then
			Door.CanCollide = false
			Door.Transparency = 0.5
			wait(2)
			Door.CanCollide = true
			Door.Transparency = 0
		end
	end
end
Door.Touched:Connect(onTouch)

And, don't listen to Daniel. To be honest, he is an idiot. He obviously didn't bother to read and understand the guidelines (not kidding, Daniel).

I think you can only do this with FilteringEnabled on.

(ADD THIS TO STARTERPACK OR STARTERCHARACTERSCRIPTS)

In a local script:

--MAKE SURE FILTERINGENABLED IS ON (check it on workspace properties)
--No need for RemoteFunctions, since this is for the Local Player only

wait(1) -- waits for the player to load in

local Player = game.Players:WaitForChild(game.Players.LocalPlayer.Name)
local Character = Player.Character

local BlockName = "Door" -- change this to the name of the block you want the player to be able to walk through
local Time = 1 -- how long the door will remain open(in seconds)

Character.Torso.Touched:connect(function(hit)
	if hit.Name == BlockName and hit.CanCollide == true then 
		print("" .. Player.Name .. " has touched" .. BlockName .. "!")
		hit.CanCollide = false 
		hit.Transparency = 0.5
		wait(Time)
		hit.CanCollide = true 
		hit.Transparency = 0
	end
end)

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