What's wrong with this? The second function in line 4 is marked in red (in Roblox Studio) and it says: expected identifier, got 'function'?
local Door = script.Parent local Owner = Door.Parent.OwnerName function onTouched:connect(function(Hit) local Character = Hit.Parent local Player = game.Players:GetPlayerFromCharacter(Character) if Player and Player.Name ~= Owner.Value then Character:BreakJoints() end end Door.Touched:connect(OnTouched)
You're attempting to define an anonymous function while still connecting the function in a connection statement. Just define the function name on line 4
.
local Door = script.Parent local Owner = Door.Parent.OwnerName function onTouched(Hit) local Character = Hit.Parent local Player = game.Players:GetPlayerFromCharacter(Character) if Player and Player.Name ~= Owner.Value then Character:BreakJoints() end end Door.Touched:connect(OnTouched)