Invisible Parts Appearing When Touching a Button

You can write your topic however you want, but you need to answer these questions:
Hello, I’m trying to make the invisible parts appear when I touch a button through a remote event. But I can’t seem to make it work.

I want it to be only visible to the person that touched the button.
The invisible parts are selected, and the button is right beside it

I’ve tried so many different ways to do it. I tried to look up some tutorials, but I couldn’t find any
These are my scripts:

-- Server Side Script (Normal Script)
local rs = game:GetService("ReplicatedStorage")
local buttonEvent = rs:WaitForChild("buttonFired")
local button = workspace.Buttons.ButtoNTest
local Players = game:GetService("Players")
button.Touched:Connect(function(hit)
	local something = hit.Parent
	local player = Players:GetPlayerFromCharacter(something)
	buttonEvent:FireClient(player)
-- Client Script(Local Script)
local RS = game:GetService("ReplicatedStorage")
local buttonEvent = RS:WaitForChild("buttonFired")
local IP = workspace.Invisible:GetChildren() -- Invisible Parts

local function touchFunction()
	IP.Transparency = 0 -- Trying to make the invisible parts visible and collidable
	IP.CanCollide = true
end

buttonEvent.OnClientEvent:Connect(touchFunction)
end)

Your IP variable refers to a table / a list of items. The line IP.Transparency = 0 will simply write a property named Transparency to the table, rather than to the elements of the table.
You’ll have to loop through the elements and assign the properties to each separately, like so:

for i,p in pairs(IP) do -- i = index (number in your case), p = value (part in your case)
    -- Code inside this scope will run for each part with the part being assigned to p
    p.Transparency = 0
    p.CanCollide = true
end

Heads up: You can use the .Touched event on the client rather than the server to speed up the process. Just make sure to check that it’s the local player (game.Players.LocalPlayer) hitting the part.

Reference:

2 Likes