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

.Touched event argument help?

Asked by 9 years ago

So I've been trying to make a nuke that breaks the joints of whatever it touches

function destroy(brick)
    brick:BreakJoints()
end

for i = 1, 200 do
    script.Parent.Touched:connect(destroy)
    script.Parent.Size = script.Parent.Size + Vector3.new(1, 1, 1)
    script.Parent.CFrame = game.Workspace.NukeModel.Nuke.CFrame
    wait(.1)
end

When I run it, it breaks the joints of my character, but does not break the joints of whatever bricks it touches. What's going on there?

EDIT: So, it seems that the function is not being called because I am CFraming the script's parent. Without CFraming it in this way, though, it would teleport above parts it came in contact with, never allowing another object to be inside of it... Work arounds to this?

0
In my opinion, it probably isn't safe to put your Connection line [line 6] inside the loop. Consider moving it Outside the loop? Also, the problem may be that the BasePart's may be Anchored. TheeDeathCaster 2368 — 9y
0
Are these connected parts anchored? If so, try adding an un-anchor statement to your 'destroy' function. Muoshuu 580 — 9y
0
No, those connected parts are not anchored :( grasheeno 70 — 9y
0
It may be that the Touched event is not firing. ROBLOX has "This event does not fire if the part is being CFramed through something." on 'Touched' in their wiki. Muoshuu 580 — 9y
View all comments (4 more)
0
You may be right. How might I work around that? grasheeno 70 — 9y
0
You could use magnitude and automatically find parts/characters within range of your 'nuke'. Muoshuu 580 — 9y
0
That only applies if he's CFraming the part, though. I'm going to assume he's not, therefore Touched *should* fire. I haven't run into a situation where it hasn't when it should, though. User#2 0 — 9y
0
Hm.. Actually, I AM CFraming the part, to the CFrame of the NukeModel. I did this because with out that bit of programming, the resizing nuke would grow bigger and bigger and every time it came in contact with another object, it would just teleport to above it so that no object was ever inside of it... grasheeno 70 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

You should anchor them then unanchor them in the script BreakJoints() Description:Breaks any surface connection with any adjacent part, including Welds and other JointInstances.

Ad

Answer this question