How to make a model disappear?

What do I want to achieve?
In a horror game I’m making, I want a model I made to disappear when a player get to a certain point, I specifically need it to be a model though.

What steps have I taken to achieve this?
I tried ungrouping the model and adding a big invisible part for the player to touch before it disappears, then I tryed YouTube but there weren’t any tutorials on how to make models disappear.

Can anyone help? Please be very descriptive, as I know pretty much nothing about scripting.

2 Likes

Set the parent of the model to lighting. (workspace.YourModel.Parent = game.Lighting

Try something like this:

local children = game.Workspace.Model:GetDescendents ()
 for i, v in paris (children) do
  v.Transperency = 1
 end

or you can destroy the model entirely

local Model = game.Workspace.Model
Model:Destroy ()

or you can parent the model to some other place, like ServerStorage

game.Workspace.Model.Parent = game.ServerStorage

Edit: I am assuming you’re having trouble making the model disappear, not detecting if the player has touched the model

1 Like

@82esPLUS158, I’m sorry but that isn’t the best way.

Do

model.Parent = nil

When you want the model to come back, do

model.Parent = workspace

or

mode.Parent = [parent you want]
5 Likes

What I’m wanting is for a player to walk into a certain area and after touching a certain part, the model disappears.

isn’t that the same as

Model:Destroy ()

though?

Do you want other players to be able to see the model after one player has touched the model? or do you want the model to disappear fully for all players, regardless of whether they touched it or not?
Because if you want other players to see it then the script has to be inside a localScript, but if you to get rid of it for all players then it must be in a normal script.

There are some several steps to make something or in your case model disappear. You could either

  • Remove the Model entirely using :Destroy()
  • Change every part inside of the model invisible using Transparency

Here is one of the examples. This function would destroy the model if player touches the part that trigger the touched event.

local Part = "TRIGGER PART HERE" -- Touch Part
local Model = "MODEL HERE" -- Model

Part.Touched:Connect(function(Hit) -- Check if something touch the trigger part
	local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
	if Player then -- Check if it is the player that touches it
		Model:Destroy() -- Destroy the model for good
	end
end) 

No, don‘t set it to Lighting. This isn‘t an good place for store instances. Just change its parent to the ServerStorage. It will be „erased“ of the game, you will gain more speed and it will be in a sure place.

No, the game is going to be single player.

Then no need for localScripts, just use a normal script.

I know you can do it, but how? Like I said, I know nothing about scripting. Where do I put the script? In the model itself or somewhere else, is it local script or a regular script?

If it’s a single player game you could only use local scripts but is not recommended due to script stealing exploits.

No I’m pretty sure you can use normal scripts. I think he means he’s going for 1 player servers, not having many players in one server and placing them in different maps.

Yep, I’m going for 1 player servers

Then you should do this
Place this script inside Workspace.

local Model = game.Workspace.Model -- you must reference your Model correctly!
local children = Model:GetDescendents ()

for i, v in pairs (children) do
 v.Touched:Connect(function(hit)
  local Players = game:GetService("Players")
  local PlayerTouched = Players:GetPlayerFromCharacter (hit.Parent)
  if PlayerTouched then
   Model:Destroy()
  end
 end
end

One more thing, local script or normal script?

If it’s a 1 player game, use a regular script. No need for a local script, unless you have a 2 player game targeting 1 player.

normal script, localScript will also do, but as @BurgerBurner pointed out, there are vulnerabilities which can be exploited.

Also, if I make the model non collide, will it still delete like it’s supposed to? I don’t want the player to be suddenly stopped by an object and then it disappears.