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

Why is this error coming up when I run my code? And how can I stop it?

Asked by 3 years ago
Edited 3 years ago

I keep on getting this error when I run this code, but I have no idea why.

Move.OnServerEvent:Connect(function(person, key, Value, MouseValue)-- Key detection for all players
    print(Value, CanMove1, grounded)
    if Value == true and CanMove1 == true and grounded == false then --and MouseValue == false then
                print(key)
        if key == W then
            print(person.name)
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            CanMove2 = true
            print("Should be true")
        end if key == A then
            print(person.name)
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            CanMove3 = true
        end if key == S then
            print(person.name)
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            CanMove4 = true
        end if key == D then
            print(person.name)
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            CanMove5 = true
        end if key == Space then
            print(Space)
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            CanMove6 = true
        end if key == R then
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            Name:Destroy()
            function spawnman(person)-- change this when you're gonna do more keys
        end
    elseif Value == false then
        if key == W then
            CanMove2 = false
        elseif key == A then
            CanMove3 = false
        elseif key == S then
            CanMove4 = false
        elseif key == D then
            CanMove5 = false
        end 
        if key == "Mouse" then
            print(MouseValue)
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            --local Mousex = Vector3.new(0,MouseValue.X * -82 + 180, 0)
            --local Var = Name.Union.Orientation
            local Var2 = Name.Union.Orientation + one
            Name.Union.Orientation = Var2
            --Var -= Vector3.new(0,MouseValue.X * -82 + 180, 0)
            --Name.Union.Orientation = Var + Vector3.new(0,MouseValue.X * -82 + 180, 0)
            Name.Head.Orientation = Vector3.new(MouseValue.Y * -80,0, 0) + Name.Union.Orientation
            --Name.Focus.Orientation = Name.Head.Orientation
            Name.Focus.CFrame = Name.Head.CFrame * CFrame.new(4,2.5,6)
            --local Orient = Name.Focus.Orientation
            Name.Neck.Orientation = Name.Union.Orientation
            --Name.Head.Orientation = Orient
            one = Vector3.new(0,MouseValue.X * -85 + 180, 0) - Name.Union.Orientation
        end
    end
end

The error is on the last end. Here is the error

ServerScriptService.Spawn/Move:197: Expected 'end' (to close 'function' at line 129), got <eof>; did you forget to close 'then' at line 169?

2
This code is extremely inefficient. The error in layman's terms means that you forgot to close an open scope, and is instead met with the End Of File. You didn't close your if-block from line 3; there are meant to be four 'end' keywords present. Ziffixture 6913 — 3y
0
Yeah I thought there would probably be a more efficient way to do that, but how? Longjohnnn 28 — 3y
0
Oh wait I see it. Wow that's terrible. Longjohnnn 28 — 3y
0
oh wait Longjohnnn 28 — 3y
View all comments (3 more)
0
this script is for all players in the server hence why I'm not using elseif Longjohnnn 28 — 3y
0
I think it would be a good idea to use one script for all the players movement right? Longjohnnn 28 — 3y
0
Please send me your full code and the :FireServer() code happy_gagarara12 13 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
Move.OnServerEvent:Connect(function(person, key, Value, MouseValue)-- Key detection for all players
    print(Value, CanMove1, grounded)
    if Value == true and CanMove1 == true and grounded == false then --and MouseValue == false then
        print(key)
        if key == W then
            print(person.name)
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            CanMove2 = true
            print("Should be true")
        end if key == A then
            print(person.name)
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            CanMove3 = true
        end if key == S then
            print(person.name)
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            CanMove4 = true
        end if key == D then
            print(person.name)
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            CanMove5 = true
        end if key == Space then
            print(Space)
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            CanMove6 = true
        end if key == R then
            Name = game.Workspace:WaitForChild(person.name.."Tempman")
            Name:Destroy()
            function spawnman(person)-- change this when you're gonna do more keys
            end
                end
        elseif Value == false then
            if key == W then
                CanMove2 = false
            elseif key == A then
                CanMove3 = false
            elseif key == S then
                CanMove4 = false
            elseif key == D then
                CanMove5 = false
            end 
            if key == "Mouse" then
                print(MouseValue)
                Name = game.Workspace:WaitForChild(person.name.."Tempman")
                --local Mousex = Vector3.new(0,MouseValue.X * -82 + 180, 0)
                --local Var = Name.Union.Orientation
                local Var2 = Name.Union.Orientation + one
                Name.Union.Orientation = Var2
                --Var -= Vector3.new(0,MouseValue.X * -82 + 180, 0)
                --Name.Union.Orientation = Var + Vector3.new(0,MouseValue.X * -82 + 180, 0)
                Name.Head.Orientation = Vector3.new(MouseValue.Y * -80,0, 0) + Name.Union.Orientation
                --Name.Focus.Orientation = Name.Head.Orientation
                Name.Focus.CFrame = Name.Head.CFrame * CFrame.new(4,2.5,6)
                --local Orient = Name.Focus.Orientation
                Name.Neck.Orientation = Name.Union.Orientation
                --Name.Head.Orientation = Orient
                one = Vector3.new(0,MouseValue.X * -85 + 180, 0) - Name.Union.Orientation
            end
        end
    end
end)

Here, you forgot "end)" at the end of your code. Hope It worked

Edit: you also forgot to close 'then'

Ad

Answer this question