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 ; did you forget to close 'then' at line 169?

7 comments
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.
Yeah I thought there would probably be a more efficient way to do that, but how?
Oh wait I see it. Wow that's terrible.
oh wait
this script is for all players in the server hence why I'm not using elseif
I think it would be a good idea to use one script for all the players movement right?
Please send me your full code and the :FireServer() code