First of all, Make a local script and put it in StarterPack or StarterPlayerScripts
local UIS = game:GetService("UserInputService")
local Visible = true
local player = game.Players.LocalPlayer
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.R then
if Visible == true then
game.ReplicatedStorage.RemoteEvent1:FireServer()
Visible = false
elseif Visible == false then
game.ReplicatedStorage.RemoteEvent2:FireServer()
Visible = true
end
end
end)
You need to make 2 RemoteEvents. Put them both in ReplicatedStorage. Name the first "RemoteEvent1" And the second "RemoteEvent2"
Now create a server script ("script") and put it in ServerScriptService
game.ReplicatedStorage.RemoteEvent1.OnServerEvent:Connect(function(plr)
for i,v in pairs(game.Workspace[plr.Name]:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.Transparency = 1
end
end
end)
Then make another server script and put it in the same place. Make the code for that script
game.ReplicatedStorage.RemoteEvent2.OnServerEvent:Connect(function(plr)
for i,v in pairs(game.Workspace[plr.Name]:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.Transparency = 0
end
end
end)
I've tested this out and it worked, enjoy
3 comments
v:IsA("BasePart") will take all the part types
and you don't need two remote events
He used meshpart and part in the original so I wasnt sure he wanted everything invisible