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

how to add more than 1 to functions?

I am trying to add more than 1 variable to a function when calling the player who started it like a touch event but it wont let me it works perfectly fine until i add a second variable

function asda(hit) print(hit.Parent) end game.workspace.part.Touched:connect(asda)

but if i add a second one

function asda(hit, num) print(hit.Parent) end how do i call the second one cause it dont work

2 comments

0

As you have connected the function to the Touched event, it is only getting passed the one value that Touched provides, which is the touching part. If you can explain what other information you need within the function then it will be possible to let you know how to do what you want.

0

i just want to beable to send another value with the part that touches but when i do it doesnt work im literaly doing this so it can send either the number 1 or 2 through with it thats all

1 answer

✓ Accepted answer

To do what you want, you can do the following:

function asda(hit, num)
	print(hit.Parent)
	print(num)
end

game.workspace.part.Touched:Connect(function(hit)
	local num = 2 -- whatever you want num to be here
	asda(hit, num)
end)

Though num could just as easily be calculated within the asda function I would think.

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