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

How do I add touched to model?

Asked by 6 years ago
script.Parent.Touched:connect(function(h)
    if h.Parent.Name == "Basic Cakepop" or h.Parent.Name == "U" then
        h.Parent.Name = "White Cakepop"
        if h.Parent:FindFirstChild("drink") ~= nil then
            h.Parent.drink.Transparency = 0
            h.Parent.drink.BrickColor = BrickColor.new("White")
        end
    end
end)

I keep getting the Error "18:24:45.398 - Touched is not a valid member of Model"

1 answer

Log in to vote
0
Answered by 6 years ago

Models are simply meant to organize things, as it says in the wiki. That means the model doesn’t have the properties of a part, which also means it doesn’t have the .Touched function.

You can put an invisible, non-collidable part on the model so when players touch the part, stuff happens. You can also use .magnitude I think, but I would just prefer making the invisible part.

0
... Sorry for wasting your time, just realized I just had the script grouped in a model, not inside a part/meshpart SoveDaSpooker 3 — 6y
Ad

Answer this question