Hi, I'm new to LUA and I don't know much. Does anyone know how to fix this code?
local Info = TweenInfo.new(2) local DoorA = script.Parent.Parent.Door local Info = TweenInfo.new(2) local Key = Character:FindFirstChild("Keycard")or Player.Backpack:FindFirstChild("Keycard") Door.Touched:Connect(function(Hit) if Key then script.Parent.ClickDetector.MouseClick:Connect(function() script.Parent.CanCollide = false local Change = {Position = Vector3.new(2.721, 3.705, 27.59)} local Tween = Service:Create(DoorA, Info, Change) Tween:Play() end) local Info = TweenInfo.new(2) wait(15) script.Parent.ClickDetector.MouseClick:Connect(function() script.Parent.CanCollide = false local Change = {Position = Vector3.new(2.721, 3.705, 31.704)} local Tween = Service:Create(DoorA, Info, Change) Tween:Play() end) end
I get this message at output: 18:57:13.454 - Workspace.Model.Script:28: 'end' expected (to close 'function' at line 6) near '<eof>'
Hey, i've looked at your script and found that you didn't give an ending to 2 functions in the script here's a fix!
local Info = TweenInfo.new(2) local DoorA = script.Parent.Parent.Door local Info = TweenInfo.new(2) local Key = Character:FindFirstChild("Keycard")or Player.Backpack:FindFirstChild("Keycard") Door.Touched:Connect(function(Hit) if Key then script.Parent.ClickDetector.MouseClick:Connect(function() script.Parent.CanCollide = false local Change = {Position = Vector3.new(2.721, 3.705, 27.59)} local Tween = Service:Create(DoorA, Info, Change) Tween:Play() end) local Info = TweenInfo.new(2) wait(15) script.Parent.ClickDetector.MouseClick:Connect(function() script.Parent.CanCollide = false local Change = {Position = Vector3.new(2.721, 3.705, 31.704)} local Tween = Service:Create(DoorA, Info, Change) Tween:Play() end) end end)
if it worked please accept, thank you.
The fix is really simple. Every time the error "Workspace.Model.Script:28: 'end' expected (to close 'function' at line ..)" or anything which expected an end appears, it means that you have forgot to close off the function!
Which basically means that you didn't put an end to the script. So there is no real issue with the script, it is just that you forgot to close a function with an end I am currently pretty busy so I wont really be able to paste in your script with the ends, but this should not be hard to put in as you can just check which functions don't have an end. I hope this helped you!