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

Part touching Part help?

Asked by 9 years ago

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

Log in to vote
0
Answered by
ImageLabel 1541 Moderation Voter
9 years ago

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.

0
Tried that, didn't work. Put in the right name for assassin. TealTeam 40 — 9y
0
test it out now and set tornado to the actual tornado ImageLabel 1541 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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)
0
That doesn't work either. Is this just impossible to do? TealTeam 40 — 9y
0
Its hard to produce a reliable and accurate answer with the little information you gave us! UserOnly20Characters 890 — 9y

Answer this question