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

How do i change a blocks value only for one player?

Asked by
otto045 41
6 years ago

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

Log in to vote
0
Answered by 6 years ago

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.

Community Guidelines

How to post a good question

About Scripting Helpers

0
I allready tried but i can't find out how to do i locally otto045 41 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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).

Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago
Edited 6 years ago

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)

Answer this question