How do I make parts appear on-touch, but only for the person who touches it

I am trying to make an obby that when you hit an invisible brick, more obstacles appear, but only for the people who touch the brick!

I do not know how to make this happen. I have tried using the bricks parented into the camera, and using both local and normal scripts, but nothing is working. I have checked the dev hub and found nothing. If one of you amazing people could explain this to me, I would be extremely grateful!

5 Likes

Use a LocalScript rather than a Script if you only want it on the client who touched the part.

1 Like

Make sure to use localPlayer also (adding on to what’s been said above)

1 Like

Use for example, a script, and then fire a event, :FireClient(plr)

Foremost, make sure that FilteringEnabled it turned on for your game. I believe it is now default for all games, but just incase.

Next, I would use a Local Script in the PlayerGui or some other player related space and use a script similar to this:

local model = game.ReplicatedStorage:WaitForChild('ObbyParts') -- this would be where more of your obby parts are
local button = game.Workspace:WaitForChild('Button') -- the part you want to be the trigger

button.Touched:connect(function(p)
    if p.Parent == game.Players.LocalPlayer.Character then
        model:Clone().Parent = game.Workspace
    end
end)

This will make the model located in ReplicatedStorage named ‘ObbyParts’ appear in ONLY the players workspace when they touch the button (a part in the workspace named Button)

Here’s how it looks on the client, and then the server (as you can see the obby is only visible in the players workspace):

Let me know if you have any other questions :slight_smile:

9 Likes

Have the script be in a LocalScript in StarterPlayerScripts.

And add this in the line above the Touched event:

local players = game:GetService("Players")
local localPlayer = players.LocalPlayer

Also, add this in the line below the Touched event:

local player = players:GetPlayerFromCharacter(hit.Parent)
if (player and player == localPlayer) then

Thanks, man! It worked! Thank you so much! I understand it now :slight_smile:

1 Like