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

Is there a way to use variables in a :Connect event?

The question is a bit vague but here's what I'm asking in better context-

local function printText(words)
	print(words)
end

part.Touched:Connect(printText("Why'd you touch me :("))
part2.Touched:Connect(printText("STOP THAT"))

I'm not sure if this is possible, I usually don't use this method but I'm trying it out so I don't have to copy and paste the same piece of code over and over.

1 answer

This should work, I hope.

local function printText(words)
    print(words)
end

part.Touched:Connect(function()
	printText("Why'd you touch me :(")
end)

part2.Touched:Connect(function()
	printText("STOP THAT")
end)

2 comments

0

Nah, that's what I've been doing which makes me spam a bunch of touched functions for no reason

0

I don't see what your trying to do sorry

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