(Q) best way to remove part only for one person?

Greetings, fellow developers.
I am currently doing some things to improve and now im stuck with bridge that consisting 15 parts. I want to make it so that when a player touches a part, it disappears only for that player. I have found that using RemoteEvents to communicate between script and a local script is the best approach, but it may be time-consuming as I would need to create 15 RemoteEvents, or even more. Is there a more efficient way to achieve this?

You would simply create a LocalScript and make that work, it would be Local

1 Like

No you don’t. Just reuse the same RemoteEvent and send different data (different part) through the function.

Just like what @Dede_4242 has said, using a LocalScript only achieves your goal.

3 Likes

This script should work, it wasnt tested and I never actually tried doing this tho:

local part = path.to.part

local function onTouch(hit)
    if hit == part then
        part.Transparency = 1
    end
end

script.Parent.Touched:Connect(onTouch)

LocalScript under any part of the body you want

1 Like

LocalScripts do not work in this case because the parent is not suitable… You have to parent it under a player’s character and readjust some of the script.

``Also, why are you using RemoteEvents for this?

I looks like I am a bit late here, but here’s a suggestion that doesn’t involve any remote events, and it is quite simple to understand. What I was thinking was that you would have a local script in StarterPlayerScripts and some sort of value, lets say a boolvalue and call it “Disappear”, that would be a child of the part that disappears:

for i, v in pairs(game.Workspace:GetDescendants()) do -- gets all everything in workspace
	if v:IsA("BoolValue") and v.Name == "Disappear" then -- checks if what the for loop got is a boolvalue and it is called "Disappear"
		local debounce = true
		v.Parent.Touched:Connect(function(hit) -- when the part is touched
			if not hit.Parent:FindFirstChild("Humanoid") then return end -- if it is a character with a humanoid

			if debounce == true then
				debounce = false

				wait(0.3) -- waits a bit for it to disappear
				v.Parent.Transparency = 1
				v.Parent.CanCollide = false

				wait(2) -- waits 2 seconds, then reappears

				v.Parent.Transparency = 0 -- reappears
				v.Parent.CanCollide = true
				debounce = true
			end
		end)
	end
end

So essentially, you would just put that value under all of the 15 parts.

1 Like

Just forgot at all that I can use local scripts for it and I was giving signal from script to local script. That`s why I was using them ¯ \ _ (ツ)_/¯

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.