local ReplicatedStorage = game:GetService("ReplicatedStorage") local createPartEvent = Instance.new("RemoteEvent", ReplicatedStorage) createPartEvent.Name = "CreatePartEvent" local function onCreatePartFired(player, color, position) print(player.Name, "wants to create a part") local newPart = Instance.new("Part") newPart.BrickColor = color newPart.Position = position newPart.Parent = game.Workspace end createPartEvent.OnServerEvent:Connect(onCreatePartFired)
When use this even it needs to be "local function OnCreatePartFired" or else it won't work. I just know one works and the other doesn't. Can someone explain why it needs to be a local function and can't just be "function OnCreatePartFired"?
if you are asking why things need to be local then I believe I can tell you what you are looking for, local ensures you are not trying to change something that is called function, it also is useful for variables when type in "hotdog" local makes it so that it appears as a variable rather than changing something called hotdog
hope that helps!