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

:Connect(function() script not working properly?

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

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.

2 comments

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.

0

btw if it worked press accept question

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)

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