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

Getting an error 'end expected'?

Asked by
Aozwel 71
4 years ago
Edited 4 years ago

Hey there, new scripter here,

The script works fine but i get an error causing it to not work as intended,

Error = Players.Aozwel.PlayerGui.MainDialogs.Stage2.StatusBar.Frame.TextLabel.LocalScri:47: 'end' expected (to close 'if' at line 15) near '<eof>'

Code =

-- STAGE 2
local dialogGui = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local object = script.Parent
local host = workspace.Host
local guiObject = script.Parent
local myThread = coroutine.running()

function continueDialog()
    coroutine.resume(myThread)
end

host.Touched:Connect(continueDialog)
workspace.host.Touched:Connect(function(hit)
 if hit.Parent:findFirstChild("Humanoid") then
    guiObject.Visible = true

-- Require module


local TypeWriter = require(ReplicatedStorage:WaitForChild("TypeWriter"))
    coroutine.yield()
    wait(1)
TypeWriter.typeWrite(script.Parent, "Head on over to the Potion Class!")
    wait(1)
    TypeWriter.typeWrite(script.Parent, "Hello there students my name is Professor Herbert")
    wait(1)
    TypeWriter.typeWrite(script.Parent, "Would you like to help me create my newest Potion?")
    wait(1)
    TypeWriter.typeWrite(script.Parent, "Great! I’ll need the following ingredients..")
    wait(1)
    TypeWriter.typeWrite(script.Parent, "They should all be hidden somewhere within the classes go look!")
    wait(1)


object.AnchorPoint = Vector2.new(0, 0)
object.Position = UDim2.new{0, 0},{0, 0}


object:TweenPosition(UDim2.new(0, 0, -10.04, 0), Enum.EasingDirection.In, Enum.EasingStyle.Sine,0.5)

wait(2)

script.parent.Visible = false
    if script.parent.visible == false then print("Worked!")

end

Thanks,

0
After line 47 put an end). You didn't close the function body with the end keyword. The parenthesis is there to close of the :Connect() call. User#24403 69 — 4y

1 answer

Log in to vote
2
Answered by
cailir 284 Moderation Voter
4 years ago
Edited 4 years ago

Hello, an "end" is expected to close the if at line 15. Your code shoud be:

-- STAGE 2
local dialogGui = script.Parent
--local ReplicatedStorage = game:GetService("ReplicatedStorage")
local object = script.Parent
local host = workspace.Host
local guiObject = script.Parent
local myThread = coroutine.running()

-- Local type writer
function localTypeWriter(textElement, goal)
    for i=1, string.len(goal), 1 do
        textElement.Text = string.sub(goal,1,i)
        wait(.2)
    end
end

function continueDialog()
    coroutine.resume(myThread)
end

host.Touched:Connect(continueDialog)
workspace.host.Touched:Connect(function(hit) -- Missing end for this function
    if hit.Parent:findFirstChild("Humanoid") then -- Missing end for this if
        guiObject.Visible = true

        -- Require module
        --local TypeWriter = require(ReplicatedStorage:WaitForChild("TypeWriter"))
        --coroutine.yield()
        -- Ajust the wait values to fit your time.
        wait(1)
        localTypeWriter(script.Parent, "Head on over to the Potion Class!")
        wait(1)
        localTypeWriter(script.Parent, "Hello there students my name is Professor Herbert")
        wait(1)
        localTypeWriter(script.Parent, "Would you like to help me create my newest Potion?")
        wait(1)
        localTypeWriter(script.Parent, "Great! I’ll need the following ingredients..")
        wait(1)
        localTypeWriter(script.Parent, "They should all be hidden somewhere within the classes go look!")
        wait(1)


        object.AnchorPoint = Vector2.new(0, 0)
        object.Position = UDim2.new{0, 0},{0, 0}


        object:TweenPosition(UDim2.new(0, 0, -10.04, 0), Enum.EasingDirection.In, Enum.EasingStyle.Sine,0.5)

        wait(2)

        script.parent.Visible = false
        if script.parent.Visible == false then 
            print("Worked!")
        end
    end -- Line added
end) -- Line added

Or maybe your are missing the end for the if at line 45.

Some identation should help you next time ;)

1
That just gave me another 'End' error elsewhere? Players.Aozwel.PlayerGui.MainDialogs.Stage2.StatusBar.Frame.TextLabel.LocalScri:48: 'end' expected (to close 'function' at line 14) near '<eof>' Aozwel 71 — 4y
0
Got this now? Players.Aozwel.PlayerGui.MainDialogs.Stage2.StatusBar.Frame.TextLabel.LocalScri:49: ')' expected (to close '(' at line 14) near '<eof>' Aozwel 71 — 4y
1
Sorry, I didin't found the missing bracket, have you copied the full code? cailir 284 — 4y
0
I have seemed to have got it working for the most part, However the text isnt appearing at Line 24, Just the gui pops up Aozwel 71 — 4y
View all comments (14 more)
1
Have you copied the TypeWriter script from roblox developer wiki? Or you forgot it? cailir 284 — 4y
0
Yeah the TypeWriter is from the wiki Aozwel 71 — 4y
1
I didn't found a way to make the TypeWriter works... So I made a local TypeWriter (code edited) cailir 284 — 4y
0
Alright lemme try that, However i did manage to get it to work with my script by removing the Touched and Visible = true so im wondering if thats the issue i need to fix? Aozwel 71 — 4y
1
At line 51, "Visible" was starting lowercase, while it should be starting upercase cailir 284 — 4y
0
Yours seems to be doing the same thing as mine and not displaying the Text, However i noticed "localTypeWriter" has a blue line under it?, Not sure if thats a problem but i see no Errors in output, Aozwel 71 — 4y
1
I missed an "r" at the funtion name, that's why the blue lines under the code. cailir 284 — 4y
0
Still nothing, Not sure what is causing this but its very close to being able to work Aozwel 71 — 4y
1
I've created a test zone, and it works now. Just remove the "coroutine.yield()" and ajust the wait time. cailir 284 — 4y
0
It worked, Thanks so much for your time, However how would i change the settings like speed and sutff?, Also how would i go about making it a cooldown cause rn it can be spammed Aozwel 71 — 4y
1
Speed is just adjust the wait() values, "sutff"? I didin't understood that. For the cooldown just google "Roblox Debounce" and you will found an solution. cailir 284 — 4y
0
I meant like the speed of the Text generating cause its rather slow at the moment Aozwel 71 — 4y
2
Just go at the localTypeWriter function and decrease it wait value. cailir 284 — 4y
0
Thanks for all your help!, Really appreciate it, I looked into the debounce thing tho i'm unsure were i should place it in my Script as i get the End errors again Aozwel 71 — 4y
Ad

Answer this question