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

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

Asked by 8 years ago
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

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". pwnd64 106 — 8y
2
Depends if the game is FilteringEnabled or not. With that, it would depend on if you would need to use LocalParts or not. M39a9am3R 3210 — 8y
0
I don't have filtering enabled. james24dj 90 — 8y
0
You'll have to use it. Roblox won't allow you to do such things without FilteringEnabled. gskw 1046 — 8y
0
Ok, I enabled. Now what? james24dj 90 — 8y

1 answer

Log in to vote
0
Answered by
gskw 1046 Moderation Voter
8 years ago

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.

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. james24dj 90 — 8y
0
Yeah. It was just to clarify. gskw 1046 — 8y
Ad

Answer this question