Hi guys!
Currently, I’m trying to make a model that when you press on a button, the model disappear/ appear!
I have been struggling with it, for a while! I hope you can help me!
THANK YOU!
Hi guys!
Currently, I’m trying to make a model that when you press on a button, the model disappear/ appear!
I have been struggling with it, for a while! I hope you can help me!
THANK YOU!
You’ll want to add a ClickDetector
into a part, and then use the MouseClick
event to detect when a player clicks on it.
For example…
local ClickDetector = game.Workspace.Part.ClickDetector
ClickDetector.MouseClick:Connect(function(Player)
ClickDetector.Parent.Transparency = 1
end
If you wanted to do a Model…
local ClickDetector = game.Workspace.Model.ClickDetector
ClickDetector.MouseClick:Connect(function(Player)
for i,v in pairs(ClickDetector.Parent:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 1
end
end
end
Hope this helps
First, thank you! Can I do it with another part. I mean that I need to click a button, and that button makes it be transparent! (Another part, that isn’t on the model)
Yep, you just need to change where the location of the ClickDetector and the Model is
EG:
local ClickDetector = game.Workspace.Button.ClickDetector
local Model = game.Workspace.Model
Then just change the above for loop
to Model:GetDescendants()
Thank you so much! That really helped me!
Hiii! I don’t know why but when I’m trying to do it, It’s not working would you mind to do for me a model of it?
You could make a table of the children of the model
(use the Getchildren() function for that)
then add a boolean value to the model then add a button then add a script with a touched event so it changes it to true
Then use an if statement to check that value then makes it so if it’s true then make it transparent with that table.
Turns out since a Model does not have a Transparency
property, you’d need to loop through all the parts with the GetChildren()
function instead which basically gets all the current Objects in that current location (I’ll show an example)
for _, Part in pairs(workspace.Model:GetChildren()) do
if Part:IsA("Part") or Part:IsA("UnionOperation") then
Part.Transparency = 1
end
end