Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

.Touched event argument help?

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?

8 comments

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.

0

Are these connected parts anchored? If so, try adding an un-anchor statement to your 'destroy' function.

0

No, those connected parts are not anchored :(

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.

0

You may be right. How might I work around that?

0

You could use magnitude and automatically find parts/characters within range of your 'nuke'.

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.

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...

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.