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

I've got an error I just can't seem to squash, can anyone help me out?

Asked by
bobder2 135
10 years ago
01this = script.Parent
02 
03function fademodel(part, modelname)
04    if part ~= nil then
05        model = game.Lighting.Models:findFirstChild(modelname)
06        modelchildren = model:GetChildren()
07        tempmodel = Instance.new("Model")
08        tempmodel.Name = model.Name
09        tempmodel.Parent = game.workspace.FadeModelTest.Models
10        for i, v in ipairs(modelchildren) do
11 
12            local t = v:clone()
13            local temp = v.CFrame
14            t.Parent = tempmodel
15            t.CFrame = temp
View all 23 lines...

This is my script. I'm trying to make a part that, when you touch it, it will bring a model out from the lighting but in a more light on resources kind of way. The issue is, that this line: this.Touched:connect(fademodel(part)) is throwing the error: Attempt to connect failed: Passed value is not a function

I've got a feeling it's just some dumb typo that I can't seem to find, but it might be something else. Any help would be appreciated.

1 answer

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Touched events have one built in parameter. It is built in, so you do not have to define it with an argument. This parameter is hit or part, which is automatically equal to the part that hit the brick. Don't try adding other parameters, as it probably won't work right. You should also check if the part that touched the brick is truly a player. For this we can use the GetPlayerFromCharacter() method.

Also, you're basically creating a clone of the model you put in Lighting, and putting it in workspace. But why would you do it the way you're doing it, instead of just using the Clone()method? So,

01this = script.Parent
02modelname = "modenamehere"
03 
04function fademodel(part)
05    if game.Players:GetPlayerFromCharacter(part.Parent) then
06        local clone = game.Lighting[modelname]:Clone()
07        clone.Parent = game.Workspace.FadeModelTest.Models
08    end
09end
10 
11print("here")
12this.Touched:connect(fademodel)

Hope i helped!

0
Thanks for the help, I wanted to do it with the for loop because I'm going to be using this with very high brick count models so I don't want to lag players by moving everything at once. bobder2 135 — 10y
Ad

Answer this question