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

Part touching Part help?

I know I asked this before, and I thought I fixed it, but it wasn't fixed.

function onTouched(hit)
if hit.Name=="EF1B"
then
hit.Anchored=false
end
end
script.Parent.Touched:connect(onTouched)

The thing that touches EF1B is a tornado, but when the tornado touches EF1B, it doesn't unanchor. Any help?

2 answers

I assume from your post that EF1B is the part that is being touched -- script.Parent, and the tornado is named something other than EF1B. I labeled everything so that you'd understand just what each of them represent.

The parameter assassin represents emitter (what is doing the touching), and victim is the receiver.

local victim = script.Parent -- EF1B
local tornado = workspace['path to tornado'] 

victim.Touched:connect(function (assassin)
	-- whenever victim is touched
	if assassin and tornado and assassin:IsDescendantOf (tornado) then
		-- check for assassin's name
		victim.Anchored = true	
		-- code
	end
end)

Edit: set tornado to the model and the if statement will check if assassin is a descendant of the model, if so, the part will be unanchored.

2 comments

0

Tried that, didn't work. Put in the right name for assassin.

0

test it out now and set tornado to the actual tornado

Apart from the sloppy coding I don't see anything wrong.If you want to make the script more efficient then I suggest doing this.

script.Parent.Touched:connect(function(Hit)
if Hit.Parent.Name == "EF1B" or Hit.Name == "EF1B" then--I added Hit.Parent.Name so if a Descendant of an Object touches the Tornado it will retrieve Name of the Part that its Descendant to. 
Hit.Anchored = false
end)

2 comments

0

That doesn't work either. Is this just impossible to do?

0

Its hard to produce a reliable and accurate answer with the little information you gave us!

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