Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How To Make Reference Model Disappear When Touching?

Asked by 4 years ago

The model I am talking about here is the one I created as a clone of a model in ReplicatedStorage but its Parent is in Workspace. So, it is only visible in the play mode. That is why I cannot address it outside of the loop down here. I can't use Destroy() or Debris:AddItem()

while wait(math.random(10,30)) do
local GrapeCopy = Grape:Clone()
GrapeCopy.Parent = workspace
GrapeCopy.Position = Generator.Position
GrapeCopy.Velocity = Vector3.new(0,-50,0)
game:GetService('Debris'):AddItem(GrapeCopy,math.random(10,15))
end

Does anyone know how to make GrapeCopy disappear when the character touches it?

3 answers

Log in to vote
0
Answered by 4 years ago

Get the descendants and make sure their transparency is set to 1

for _, v in pairs(GrapeCopy:GetDescendants()) do
    if v:IsA("BasePart") then
        v.Transparency = 1
    end
end

or just simply send it to replicated storage.

GrapeCopy.Parent = game.ReplicatedStorage
Ad
Log in to vote
0
Answered by
Necro_las 412 Moderation Voter
4 years ago
Edited 4 years ago

You cant use Touched Event in the Model but you can use it in the Humanoid.

Humanoid.Touched:Connect(function(hit, limb) 
    if hit.Name == "GrapleCopy" then
        hit:Destroy()
    end
end)

Consider searching for some important information about touching humanoids here: https://developer.roblox.com/en-us/api-reference/event/Humanoid/Touched

Log in to vote
0
Answered by 4 years ago

Just add: GrapelCopy.PrimaryPart:Destroy().

That removes the primary part of the model, and wherever the primary part goes the whole model goes. Make sure you have a primary part in the model.

If this helped please accept this answer.

Answer this question