Can i localize a function? like this:
function SpawnShadow() local Shadow = Instance.new("Part", workspace) Shadow.Position = vector3.new(10,10,10) Shadow.Name = "Shadow" local Shadow = SpawnShadow()
Can i do that?If not is there another way? because it does not know what shadow is when i create a
function SpawnShadow() local Shadow = Instance.new("Part", workspace) Shadow.Position = vector3.new(10,10,10) Shadow.Name = "Shadow" end -- need an end to your function! -- not needed. this is only done this way if you're going to call your function from multiple places --// SpawnShadow() -- call is good enough! -- local Shadow = SpawnShadow() script.parent.MouseButton1Click:Connect(SpawnShadow) -- you can leave off the parenthesis (Round brackets as its not needed here, though calling the function from outside an event you would need them!)
if you need to look up on how to program in lua id suggest this site: https://www.tutorialspoint.com/lua/index.htm
or the Roblox luau(Similar to lua) wiki: https://developer.roblox.com/en-us/api-reference/class/Script just type in the function or object to get a list of events/functions and properties.
Hope this helps! :)