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.
COMMUNITY QUESTION
How do i change a blocks value only for one player?
3 answers
Scripting helpers isnt a request site.You have to try the code your self and as for help this is scripting helpers not scripting givers.Dude just visit this link for more information of how to post a good post.
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.

1 comment
I allready tried but i can't find out how to do i locally