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

Touch Interest and CanCollide?

So I have a part, and it is anchored and its CanCollide is false. There is a script in it that increases its size and also kills players or NPCs. It is supposed to simulate a nuclear blast. So here is the code

blast = script.Parent
blast.Touched:connect(function(part)
	print("Touched")
	local FindHumanoid = part.Parent:FindFirstChild("Humanoid")
	if FindHumanoid then
		FindHumanoid.Health = 0
	end
end)
while wait(.1)do
	blast.Size = blast.Size + Vector3.new(1,1,1)
end

When this runs it makes the part called blast seem like it is CanCollide, so it is anchored and if you run into it will move with your contact, as if it has CanCollide on. If you check the part's property you will see that it CanCollide is false. So if you remove the touch connection and function, then it will grow normally and not collide with anything, but it won't hurt you. If you remove the growth it will kill you when you touch it and it won't collide with you, but It won't grow. I'm assuming that the combination of touch interest and CanCollide messes up the collision physics of the part. I'm not sure if this is a problem with my own computer because I have looked this up and have seen videos of people doing practically exactly the same thing and not having my problem.

For Clarity try this in your own studio and you will understand what I mean

1 comment

0

So... I am on the verge to answering your question. I do see what your talking about though. I tried using a different method of killing the person but that made no difference. It might be because the humanoids parts (arms legs etc.) ARE CanCollide. Il keep testing and see what I come up with. :)

1 answer

✓ Accepted answer

I encountered two problems:

  1. The block would hit the handle of my hat, which means that the humanoid was in part.Parent.Parent, not part.Parent (but only for my hat) -- this is only a problem if you want people to die when the explosion hits their hat. Because of problem #2, I don't necessarily die when the explosion grows to hit me.
  2. When you use .Size, Roblox automatically places the part above everything else (so that it doesn't collide with them). To avoid this behaviour, you must temporarily de-parent it, like so:
-- first part of your script here
local parent = blast.Parent
while wait(0.1) do
	blast.Parent = nil
	blast.Size = blast.Size + Vector3.new(1,1,1)
	blast.Parent = parent
end

2 comments

0

That is correct! It works perfectly. I would upvote but i dont have neough rep.

0

Thanks this works

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