Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I properly write the ends to this script?

Asked by 3 years ago

I keep getting errors relating ends

local frame = script.Parent
local openSound = script.Parent.DoorOpen
local closeSound = script.Parent.DoorClose
local proximityprompt = frame.PromptAttachment.ProximityPrompt
local model = script.Parent.Parent
local frameClose = model:WaitForChild("DoorClosed")
local frameOpen = model:WaitForChild("DoorOpened")
local opened = model:WaitForChild("Opened")
local tweenService = game:GetService("TweenService")
local alarm = script.Parent.Parent.AlarmPart.Alarm
local alarm2 =  script.Parent.Parent.AlarmPart.Alarm2
local BadGuys = game:GetService("Teams")["Team2"]
local GoodGuys = game:GetService("Teams")["Team1"]
local deniedsound = script.Parent.Denied

local debounce = true
proximityprompt.Triggered:Connect(function()
    if debounce == true then
        debounce = false
        game:GetService("Players").PlayerAdded:Connect(function(Player)
            if Player.Team == BadGuys then
        openSound:Play()
        alarm:Play()
        alarm2:Play()
        tweenService:Create(frame,TweenInfo.new(.35),{CFrame = frameOpen.CFrame}):Play()
        proximityprompt.Enabled = false
        wait(45)
        closeSound:Play()
        alarm:Stop()
        alarm2:Stop()
        tweenService:Create(frame,TweenInfo.new(.35),{CFrame = frameClose.CFrame}):Play()
        wait(120)
        proximityprompt.Enabled = true
        elseif Player.Team == GoodGuys then
                deniedsound:Play()
                print("You're on the wrong team!")
                debounce = true

0
best way to do it is to format the document (script menu), and then just add and remove the ends you need to! DeceitVonWrede 0 — 3y

1 answer

Log in to vote
0
Answered by
CDXKIE 130
3 years ago

Every time you write a loop you have to define when the loop ends with.. well, end. so like:

if something == 1 then
      print("something = 1")
end

Try doing this with every loop, like the proximityprompt.Triggered:Connect() and the elseif. Also, it would be much easier to read the code if you put spaces in this way:

local thing = function()
       --The thing inside the loop has a few spaces before it, so you can read where the loop 
       --starts, whats inside the loop, etc.. if you had more loops inside the loop, you'd just add
       --more spaces.
end

The thing about the spaces might have been there in the original script, but didnt translate well into this website, but just in case i thought i'd talk about that.

Ad

Answer this question