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

Expected <eof>, got 'end' how do I fix it?

Asked by 5 years ago

I added typeof but then it says I need an =, so I put that in but then it says that: "built in global 'typeof' is overwritten here; consider using a local or changing the name" so I just got the script to how it was before, any ideas?

function Click()
    if
    player.team.teamcolor == BrickColor.Red and script.Parent.Mousebutton1Click
then
    script.Parent.Parent.Parent.Parent.Character.HumanoidRootPart.CFrame = CFrame.new(-13.2, 0.5, -35.27)
    end
end

if script.Parent.MouseButton1Click:connect(Click) and player.team == BrickColor.Blue then 
script.Parent.Parent.Parent.Parent.Character.HumanoidRootPart.CFrame = CFrame.new(-13.2, 0.5, -35.27) end
end
    script.Parent.MouseButton1Down:connect(Click)
0
... This is a easy fix you have too many ends.. and make sure you place the if on line 09 onto the function because that wont work that way.. seith14 206 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

First off, wow. That is one monstrosity of errors. You seem to have jumped into making a game too quickly without learning the scripting language. You should study a little more. Here and here are good sites.

Anyways, the problems are with your capitalisation. Lua is case sensitive, and all of Roblox Lua's events, methods, and properties are PascalCase (for example FindFirstChild, the first letter in each word is uppercase).

-- use variables, so you don't have to access something using 50938 .Parent 's 
local player = game:GetService("Players").LocalPlayer

local function Click()
    if player.TeamColor == BrickColor.Red() then
        player.Character.HumanoidRootPart.CFrame = CFrame.new(-13.2, 0.5, -35.27)
    end

    if player.TeamColor == BrickColor.Blue() then   .
        player.Character.HumanoidRootPart.CFrame = CFrame.new(-13.2, 0.5, -35.27)
    end
end

script.Parent.MouseButton1Click:Connect(Click)

On a side note, please indent your code (don't remove the indentations automatically given by Roblox Studio), as it makes your code more legible. Legibility will make code easier to debug and find errors in it.

EDIT: As others have mentioned, you have added too many ends. One end for every if, while, for, and function.

0
Thank you so much! I tried removing some ends before posting the question but none worked, this helped a lot. I will also use the sites you posted. Draxslayer539AbRA 6 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

The error you have means that you have an extra 'end' in your script for example from line 9 to 11 you have 2 ends for only 1 if statement.

Also if you take a look at first 11 lines you'll see you have a function(which you have to end) and 2 if statements(both need to have an end) which means you need 3 ends but you have 4.

I also see you didn't post full code but in first 11 lines you definitely have an extra end. Obvious fix is go through your code and remove 1 end

0
Should specify where, as well as help OP legibility-wise. User#19524 175 — 5y

Answer this question