I currently have a code that makes the Model transparent, however I am not satisfied with it yet, I have no clue how I would make it toggable, so everytime I press “1”, it would either go Transparent or Visible.
Any help is appreciated. And yes, I am aware this is Client sided, I have no idea how to make it Client and Server.
local Glove = script.Parent
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local Debounce = false
UserInputService.InputBegan:Connect(function(Input, gameProcessed)
local KeyCode = Input.KeyCode
for _,i in pairs(Glove:GetChildren()) do
if (i:IsA("MeshPart") or i:IsA("UnionOperation")) and i.Transparency ~= nil then
if KeyCode == Enum.KeyCode.One then
i.Transparency = 1
end
end
end
end)
local Glove = script.Parent
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local Debounce = false
UserInputService.InputBegan:Connect(function(Input, gameProcessed)
local KeyCode = Input.KeyCode
for _,i in pairs(Glove:GetChildren()) do
if (i:IsA("MeshPart") or i:IsA("UnionOperation")) and i.Transparency ~= nil then
if KeyCode == Enum.KeyCode.One then
i.Transparency = i.Transparency==1and 0 or 1
end
end
end
end)
To make it toggleable you would need a variable named whatever you want, (I usually call it toggle) and set it to false. Then when the event is fired it would check if toggle is false or true. Then, it would set the variable to the opposite of the current state of the variable. Also to make it server sided, you would need a RemoteEvent, (RemoteEvent | Documentation - Roblox Creator Hub) or a RemoteFunction. (RemoteFunction | Documentation - Roblox Creator Hub) There are some good tutorials on Youtube on how to do them.