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

How would I make a listening function to all the parts in a model?

Asked by 8 years ago

So I have got code already, which buys a part. But I want to introduce tables, so I've added a table. But I now need a listening function for everything in a model, so I can replace workspace.dropTwoBuy. Any ideas? ~~~~~~~~~~~~~~~~~ Prices = {5} Buyables = {game.ServerStorage.Giver2}

workspace.dropTwoBuy.Head.Touched:connect(function(x) if x.Parent.Name == owner and game.Players[owner].leaderstats.Points.Value == 5 then y = game.ServerStorage.Giver2:Clone()
y.Parent = workspace wait(1)

    workspace.dropTwoBuy:Destroy()

end

end)

~~~~~~~~~~~~~~~~~

2 answers

Log in to vote
0
Answered by
funyun 958 Moderation Voter
8 years ago

You could do a generic for loop, and listen on each instance that way.

model = workspace.Model

for _, part in pairs(model:GetChildren()) do
part.Touched:connect(function()
part.BrickColor = BrickColor.Blue()
end)
end

Sorry I can't tab on mobile.

Ad
Log in to vote
-1
Answered by 8 years ago
Prices = {5}
Buyables = {game.ServerStorage.Giver2}

workspace.dropTwoBuy.Head.Touched:connect(function(x)
    if x.Parent.Name == owner and game.Players[owner].leaderstats.Points.Value == 5 then
        y = game.ServerStorage.Giver2:Clone()
        b = workspace.Reciever
        b.Size = Vector3.new(14, 2, 4.8)    
        y.Parent = workspace
        wait(1)
        b.Position = Vector3.new(37.1, 1, -12)


        workspace.dropTwoBuy:Destroy()

    end
end)
0
There's an 'edit' button you can use for that. Perci1 4988 — 8y

Answer this question