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

:Connect(function() script not working properly?

Asked by 5 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
script.Parent.turn_tableCore.Touched:Connect(function(subject)
    if subject.Name == "turn_tableRight" then
        script.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.EnemyPart.Position) * CFrame.Angles(0, 0, math.rad(90)))
        print("touched")
    else
    end
end)

This script, along with many other (function() scripts,are just not working. Any idea why?

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Just add this at the bottom

script.Parent.turn_tableCore.Touched:Connect(subject)

and you're good to go!

script.Parent.turn_tableCore.Touched:Connect(function(subject)
    if subject.Name == "turn_tableRight" then
        script.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.EnemyPart.Position) * CFrame.Angles(0, 0, math.rad(90)))
        print("touched")
    else
    end
end)

script.Parent.turn_tableCore.Touched:Connect(subject)

this may be wrong due to this showing up "Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly." Because your question isn't really self-explanatory.

1
It wouldn't make sense for this to work at all, You're doing the exact same thing he did on the first line but instead there's no functions executing on your code, for it to work you would have to create the function first then you can use it, you can't access functions that got created like :Connect(function(subject) because It's an ' anonymous ' function which can't be reused again. Isaque232 171 — 5y
0
btw if it worked press accept question AidanTES 36 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Personally I would put a script inside of the turn_tableCore that says

script.Parent.Touched:Connect(function(subject)
    if subject.Name == "turn_tableRight" then
        script.Parent.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.EnemyPart.Position) * CFrame.Angles(0, 0, math.rad(90)))
        print("touched")
    else
    end
end)

or if you have to do it as inside of whatever then try adding print functions before the if function. I'm 90% sure it's to do with the

script.Parent.turn_tableCore

instead of that try doing

script.Parent["turn_tableCore"]Touched:Connect(function(subject)

Answer this question