Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I make this brick disappear for 1 specific player?

script.Parent.Touched:connect(function()
	local brick = script.Parent
	brick:FindFirstChild("Humanoid")
	brick.Transparency = .8
	brick.CanCollide = false
end)

In other words, how do I make it so that this brick is ONLY transparent and not "Cancollided" for him only? Like, if the player touches it, only that specific player would see it transparent and the other players will see the brick, but it won't be transparent and not "cancollided" for them. (So technically, only the person who touched the brick would be able to walk through it.)

I have Filtering Enabled

5 comments

0

You'd need to use Filtering Enabled. This makes it so that client side bricks are possible. I don't know how to use FE but if you delete the brick using a localscript then it will only be deleted for the player. This might mess up parts of your game though, because everything then has to be "FE Compatible".

2

Depends if the game is FilteringEnabled or not. With that, it would depend on if you would need to use LocalParts or not.

0

I don't have filtering enabled.

0

You'll have to use it. Roblox won't allow you to do such things without FilteringEnabled.

0

Ok, I enabled. Now what?

1 answer

When Filtering is enabled, changes done by clients won't replicate to the server and therefore to other clients. We can "abuse" this to only apply changes locally.

First, create a RemoteEvent in ReplicatedStorage. Then, place the following LocalScript in StarterGui:

game.ReplicatedStorage:WaitForChild("RemoteEvent").OnClientEvent:connect(function(brick)
	-- Any changes you want to happen go here
	brick.Transparency = .8
	brick.CanCollide = false
end)

Next, create a regular Script inside the brick:

script.Parent.Touched:connect(function(toucher)
    if not game.Players:GetPlayerFromCharacter(toucher.Parent) then return end -- Only works for players
    local brick = script.Parent
    game.ReplicatedStorage:WaitForChild("RemoteEvent"):FireClient(game.Players:GetPlayerFromCharacter(toucher.Parent), brick) -- Assuming you want to apply the changes to the player who touched it
end)

And there you go! Any questions about how it works; ask in the comments.

2 comments

0

What do you mean by "Any changes you want to happen go here"? I thought my brick going transparent and CanCollide WERE the changes.

0

Yeah. It was just to clarify.

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